aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_ondemand.c
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2009-04-22 07:48:29 -0400
committerDave Jones <davej@redhat.com>2009-06-15 11:49:41 -0400
commitcef9615a853ebc4972084f7e70b52892557420ac (patch)
tree9578c3371f57ab16be61e18aec307b450106106b /drivers/cpufreq/cpufreq_ondemand.c
parent45e3e1935e2857c54783291107d33323b3ef33c8 (diff)
[CPUFREQ] ondemand: Uncouple minimal sampling rate from HZ in NO_HZ case
With this patch you have following minimal sampling rate restrictions: Kernel restrictions: If CONFIG_NO_HZ is set, the limit is 10ms fixed. If CONFIG_NO_HZ is not set or no_hz=off boot parameter is used, the limits depend on the CONFIG_HZ option: HZ=1000: min=20000us (20ms) HZ=250: min=80000us (80ms) HZ=100: min=200000us (200ms) HW restrictions: Do not sample/poll more often than HW latency * 100 exported by the low level cpufreq HW driver The higher value of above restrictions is the minimal sampling rate that can be set (and can be seen via ondemand/sampling_rate_min sysfs file) Default sampling rate still is HW latency * 1000, but this will now end up in lower values on latest (Intel and AMD) hardware as these can switch really fast and sampling rate mostly was limited to the 80ms or 200ms (depending on whether HZ=250 or HZ=1000 is used). Signed-off-by: Thomas Renninger <trenn@suse.de> Cc: Pallipadi Venkatesh <venkatesh.pallipadi@intel.com> Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e741c339df76..a235114c3d85 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -32,6 +32,7 @@
32#define DEF_FREQUENCY_UP_THRESHOLD (80) 32#define DEF_FREQUENCY_UP_THRESHOLD (80)
33#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3) 33#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3)
34#define MICRO_FREQUENCY_UP_THRESHOLD (95) 34#define MICRO_FREQUENCY_UP_THRESHOLD (95)
35#define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000)
35#define MIN_FREQUENCY_UP_THRESHOLD (11) 36#define MIN_FREQUENCY_UP_THRESHOLD (11)
36#define MAX_FREQUENCY_UP_THRESHOLD (100) 37#define MAX_FREQUENCY_UP_THRESHOLD (100)
37 38
@@ -45,27 +46,12 @@
45 * this governor will not work. 46 * this governor will not work.
46 * All times here are in uS. 47 * All times here are in uS.
47 */ 48 */
48static unsigned int def_sampling_rate;
49#define MIN_SAMPLING_RATE_RATIO (2) 49#define MIN_SAMPLING_RATE_RATIO (2)
50/* for correct statistics, we need at least 10 ticks between each measure */
51#define MIN_STAT_SAMPLING_RATE \
52 (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
53#define MIN_SAMPLING_RATE \
54 (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
55/* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon
56 * Define the minimal settable sampling rate to the greater of:
57 * - "HW transition latency" * 100 (same as default sampling / 10)
58 * - MIN_STAT_SAMPLING_RATE
59 * To avoid that userspace shoots itself.
60*/
61static unsigned int minimum_sampling_rate(void)
62{
63 return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE);
64}
65 50
66/* This will also vanish soon with removing sampling_rate_max */ 51static unsigned int min_sampling_rate;
67#define MAX_SAMPLING_RATE (500 * def_sampling_rate) 52
68#define LATENCY_MULTIPLIER (1000) 53#define LATENCY_MULTIPLIER (1000)
54#define MIN_LATENCY_MULTIPLIER (100)
69#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) 55#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
70 56
71static void do_dbs_timer(struct work_struct *work); 57static void do_dbs_timer(struct work_struct *work);
@@ -227,7 +213,7 @@ static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
227 current->comm); 213 current->comm);
228 print_once = 1; 214 print_once = 1;
229 } 215 }
230 return sprintf(buf, "%u\n", MAX_SAMPLING_RATE); 216 return sprintf(buf, "%u\n", -1U);
231} 217}
232 218
233static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 219static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
@@ -240,7 +226,7 @@ static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
240 current->comm); 226 current->comm);
241 print_once = 1; 227 print_once = 1;
242 } 228 }
243 return sprintf(buf, "%u\n", MIN_SAMPLING_RATE); 229 return sprintf(buf, "%u\n", min_sampling_rate);
244} 230}
245 231
246#define define_one_ro(_name) \ 232#define define_one_ro(_name) \
@@ -274,7 +260,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
274 mutex_unlock(&dbs_mutex); 260 mutex_unlock(&dbs_mutex);
275 return -EINVAL; 261 return -EINVAL;
276 } 262 }
277 dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate()); 263 dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
278 mutex_unlock(&dbs_mutex); 264 mutex_unlock(&dbs_mutex);
279 265
280 return count; 266 return count;
@@ -619,12 +605,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
619 latency = policy->cpuinfo.transition_latency / 1000; 605 latency = policy->cpuinfo.transition_latency / 1000;
620 if (latency == 0) 606 if (latency == 0)
621 latency = 1; 607 latency = 1;
622 608 /* Bring kernel and HW constraints together */
623 def_sampling_rate = 609 min_sampling_rate = max(min_sampling_rate,
624 max(latency * LATENCY_MULTIPLIER, 610 MIN_LATENCY_MULTIPLIER * latency);
625 MIN_STAT_SAMPLING_RATE); 611 dbs_tuners_ins.sampling_rate =
626 612 max(min_sampling_rate,
627 dbs_tuners_ins.sampling_rate = def_sampling_rate; 613 latency * LATENCY_MULTIPLIER);
628 } 614 }
629 dbs_timer_init(this_dbs_info); 615 dbs_timer_init(this_dbs_info);
630 616
@@ -678,6 +664,16 @@ static int __init cpufreq_gov_dbs_init(void)
678 dbs_tuners_ins.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; 664 dbs_tuners_ins.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
679 dbs_tuners_ins.down_differential = 665 dbs_tuners_ins.down_differential =
680 MICRO_FREQUENCY_DOWN_DIFFERENTIAL; 666 MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
667 /*
668 * In no_hz/micro accounting case we set the minimum frequency
669 * not depending on HZ, but fixed (very low). The deferred
670 * timer might skip some samples if idle/sleeping as needed.
671 */
672 min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE;
673 } else {
674 /* For correct statistics, we need 10 ticks for each measure */
675 min_sampling_rate =
676 MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
681 } 677 }
682 678
683 kondemand_wq = create_workqueue("kondemand"); 679 kondemand_wq = create_workqueue("kondemand");