cpufreq: introduce hotplug governor
author黄涛 <huangtao@rock-chips.com>
Wed, 22 Feb 2012 06:49:20 +0000 (14:49 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 22 Feb 2012 06:51:20 +0000 (14:51 +0800)
port from ti.

Documentation/cpu-freq/governors.txt
drivers/cpufreq/Kconfig
drivers/cpufreq/Makefile
include/linux/cpufreq.h

index 51b1cd360c3363e6d4f5ee077722bff49cf18ca2..46abbcb28b7c3fcf2dc03f997089a3103c724ded 100644 (file)
@@ -231,6 +231,33 @@ is 85.
 timer_rate: Sample rate for reevaluating cpu load when the system is
 not idle.  Default is 30000 uS.
 
+2.7 Hotplug
+-----------
+
+The CPUfreq governor "hotplug" operates similary to "ondemand" and
+"conservative".  It's decisions are based primarily on CPU load.  Like
+"ondemand" the "hotplug" governor will ramp up to the highest frequency
+once the run-time tunable "up_threshold" parameter is crossed.  Like
+"conservative", the "hotplug" governor exports a "down_threshold"
+parameter that is also tunable at run-time.  When the "down_threshold"
+is crossed the CPU transitions to the next lowest frequency in the
+CPUfreq frequency table instead of decrementing the frequency based on a
+percentage of maximum load.
+
+The main reason "hotplug" governor exists is for architectures requiring
+that only the master CPU be online in order to hit low-power states
+(C-states).  OMAP4 is one such example of this.  The "hotplug" governor
+is also helpful in reducing thermal output in devices with tight thermal
+constraints.
+
+Auxillary CPUs are onlined/offline based on CPU load, but the decision
+to do so is made after averaging several sampling windows.  This is to
+reduce CPU hotplug "thrashing", which can be caused by normal system
+entropy and leads to lots of spurious plug-in and plug-out transitions.
+The number of sampling periods averaged together is tunable via the
+"hotplug_in_sampling_periods" and "hotplug_out_sampling_periods"
+run-time tunable parameters.
+
 3. The Governor Interface in the CPUfreq Core
 =============================================
 
index 194708850edea435ddb11a8f2ffab412c57f4a6e..f2f64a0b72c556c4d21ef601ed89810bc0892fdb 100644 (file)
@@ -109,6 +109,19 @@ config CPU_FREQ_DEFAULT_GOV_INTERACTIVE
          loading your cpufreq low-level hardware driver, using the
          'interactive' governor for latency-sensitive workloads.
 
+config CPU_FREQ_DEFAULT_GOV_HOTPLUG
+       bool "hotplug"
+       select CPU_FREQ_GOV_HOTPLUG
+       select CPU_FREQ_GOV_PERFORMANCE
+       help
+         Use the CPUFreq governor 'hotplug' as default. This allows you
+         to get a full dynamic frequency capable system with CPU
+         hotplug support by simply loading your cpufreq low-level
+         hardware driver.  Be aware that not all cpufreq drivers
+         support the hotplug governor. If unsure have a look at
+         the help section of the driver. Fallback governor will be the
+         performance governor.
+
 endchoice
 
 config CPU_FREQ_GOV_PERFORMANCE
@@ -211,5 +224,25 @@ depends on X86
 source "drivers/cpufreq/Kconfig.x86"
 endmenu
 
+config CPU_FREQ_GOV_HOTPLUG
+       tristate "'hotplug' cpufreq governor"
+       depends on CPU_FREQ && NO_HZ && HOTPLUG_CPU
+       help
+         'hotplug' - this driver mimics the frequency scaling behavior
+         in 'ondemand', but with several key differences.  First is
+         that frequency transitions use the CPUFreq table directly,
+         instead of incrementing in a percentage of the maximum
+         available frequency.  Second 'hotplug' will offline auxillary
+         CPUs when the system is idle, and online those CPUs once the
+         system becomes busy again.  This last feature is needed for
+         architectures which transition to low power states when only
+         the "master" CPU is online, or for thermally constrained
+         devices.
+
+         If you don't have one of these architectures or devices, use
+         'ondemand' instead.
+
+         If in doubt, say N.
+
 endif
 endmenu
index c044060a4b07315028f3179ae6e3e30435ae5187..1a5e64d6fcf3e1ab700dd979dd3cd4251ac16d9b 100644 (file)
@@ -10,6 +10,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE)  += cpufreq_userspace.o
 obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND)    += cpufreq_ondemand.o
 obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE)        += cpufreq_conservative.o
 obj-$(CONFIG_CPU_FREQ_GOV_INTERACTIVE) += cpufreq_interactive.o
+obj-$(CONFIG_CPU_FREQ_GOV_HOTPLUG)     += cpufreq_hotplug.o
 
 # CPUfreq cross-arch helpers
 obj-$(CONFIG_CPU_FREQ_TABLE)           += freq_table.o
index ae06dc9a0cda34c7947e38124849a8a095e6fdd6..6f492ea8a1ac4bc56b599f7d7b98402e24ae017a 100644 (file)
@@ -361,6 +361,9 @@ extern struct cpufreq_governor cpufreq_gov_conservative;
 #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE)
 extern struct cpufreq_governor cpufreq_gov_interactive;
 #define CPUFREQ_DEFAULT_GOVERNOR       (&cpufreq_gov_interactive)
+#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_HOTPLUG)
+extern struct cpufreq_governor cpufreq_gov_hotplug;
+#define CPUFREQ_DEFAULT_GOVERNOR       (&cpufreq_gov_hotplug)
 #endif