diff options
author | Thomas Renninger <trenn@suse.de> | 2009-04-22 07:48:29 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2009-06-15 11:49:41 -0400 |
commit | cef9615a853ebc4972084f7e70b52892557420ac (patch) | |
tree | 9578c3371f57ab16be61e18aec307b450106106b /drivers/cpufreq/cpufreq_conservative.c | |
parent | 45e3e1935e2857c54783291107d33323b3ef33c8 (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_conservative.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 7a74d175287b..06bfe1c572cd 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -42,27 +42,12 @@ | |||
42 | * this governor will not work. | 42 | * this governor will not work. |
43 | * All times here are in uS. | 43 | * All times here are in uS. |
44 | */ | 44 | */ |
45 | static unsigned int def_sampling_rate; | ||
46 | #define MIN_SAMPLING_RATE_RATIO (2) | 45 | #define MIN_SAMPLING_RATE_RATIO (2) |
47 | /* for correct statistics, we need at least 10 ticks between each measure */ | ||
48 | #define MIN_STAT_SAMPLING_RATE \ | ||
49 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | ||
50 | #define MIN_SAMPLING_RATE \ | ||
51 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
52 | /* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon | ||
53 | * Define the minimal settable sampling rate to the greater of: | ||
54 | * - "HW transition latency" * 100 (same as default sampling / 10) | ||
55 | * - MIN_STAT_SAMPLING_RATE | ||
56 | * To avoid that userspace shoots itself. | ||
57 | */ | ||
58 | static unsigned int minimum_sampling_rate(void) | ||
59 | { | ||
60 | return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE); | ||
61 | } | ||
62 | 46 | ||
63 | /* This will also vanish soon with removing sampling_rate_max */ | 47 | static unsigned int min_sampling_rate; |
64 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 48 | |
65 | #define LATENCY_MULTIPLIER (1000) | 49 | #define LATENCY_MULTIPLIER (1000) |
50 | #define MIN_LATENCY_MULTIPLIER (100) | ||
66 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 51 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
67 | #define MAX_SAMPLING_DOWN_FACTOR (10) | 52 | #define MAX_SAMPLING_DOWN_FACTOR (10) |
68 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | 53 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) |
@@ -190,7 +175,7 @@ static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | |||
190 | current->comm); | 175 | current->comm); |
191 | print_once = 1; | 176 | print_once = 1; |
192 | } | 177 | } |
193 | return sprintf(buf, "%u\n", MAX_SAMPLING_RATE); | 178 | return sprintf(buf, "%u\n", -1U); |
194 | } | 179 | } |
195 | 180 | ||
196 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 181 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) |
@@ -202,7 +187,7 @@ static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | |||
202 | "sysfs file is deprecated - used by: %s\n", current->comm); | 187 | "sysfs file is deprecated - used by: %s\n", current->comm); |
203 | print_once = 1; | 188 | print_once = 1; |
204 | } | 189 | } |
205 | return sprintf(buf, "%u\n", MIN_SAMPLING_RATE); | 190 | return sprintf(buf, "%u\n", min_sampling_rate); |
206 | } | 191 | } |
207 | 192 | ||
208 | #define define_one_ro(_name) \ | 193 | #define define_one_ro(_name) \ |
@@ -254,7 +239,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
254 | return -EINVAL; | 239 | return -EINVAL; |
255 | 240 | ||
256 | mutex_lock(&dbs_mutex); | 241 | mutex_lock(&dbs_mutex); |
257 | dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate()); | 242 | dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); |
258 | mutex_unlock(&dbs_mutex); | 243 | mutex_unlock(&dbs_mutex); |
259 | 244 | ||
260 | return count; | 245 | return count; |
@@ -601,11 +586,18 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
601 | if (latency == 0) | 586 | if (latency == 0) |
602 | latency = 1; | 587 | latency = 1; |
603 | 588 | ||
604 | def_sampling_rate = | 589 | /* |
605 | max(latency * LATENCY_MULTIPLIER, | 590 | * conservative does not implement micro like ondemand |
606 | MIN_STAT_SAMPLING_RATE); | 591 | * governor, thus we are bound to jiffes/HZ |
607 | 592 | */ | |
608 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 593 | min_sampling_rate = |
594 | MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10); | ||
595 | /* Bring kernel and HW constraints together */ | ||
596 | min_sampling_rate = max(min_sampling_rate, | ||
597 | MIN_LATENCY_MULTIPLIER * latency); | ||
598 | dbs_tuners_ins.sampling_rate = | ||
599 | max(min_sampling_rate, | ||
600 | latency * LATENCY_MULTIPLIER); | ||
609 | 601 | ||
610 | cpufreq_register_notifier( | 602 | cpufreq_register_notifier( |
611 | &dbs_cpufreq_notifier_block, | 603 | &dbs_cpufreq_notifier_block, |