aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-04-10 18:20:41 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-04-17 12:37:27 -0400
commit1b72e7fd304639f1cd49d1e11955c4974936d88c (patch)
tree3e0f6a04789bd0d92410ed3e273ee1b6bdc041de
parent5ed8a1c19d4655e6ca5768266b2f51a9d58b8a76 (diff)
cpufreq: schedutil: Use policy-dependent transition delays
Make the schedutil governor take the initial (default) value of the rate_limit_us sysfs attribute from the (new) transition_delay_us policy parameter (to be set by the scaling driver). That will allow scaling drivers to make schedutil use smaller default values of rate_limit_us and reduce the default average time interval between consecutive frequency changes. Make intel_pstate set transition_delay_us to 500. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r--drivers/cpufreq/intel_pstate.c2
-rw-r--r--include/linux/cpufreq.h7
-rw-r--r--kernel/sched/cpufreq_schedutil.c15
3 files changed, 19 insertions, 5 deletions
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index c31b72b16c2b..b7de5bd76a31 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -41,6 +41,7 @@
41#define INTEL_PSTATE_HWP_SAMPLING_INTERVAL (50 * NSEC_PER_MSEC) 41#define INTEL_PSTATE_HWP_SAMPLING_INTERVAL (50 * NSEC_PER_MSEC)
42 42
43#define INTEL_CPUFREQ_TRANSITION_LATENCY 20000 43#define INTEL_CPUFREQ_TRANSITION_LATENCY 20000
44#define INTEL_CPUFREQ_TRANSITION_DELAY 500
44 45
45#ifdef CONFIG_ACPI 46#ifdef CONFIG_ACPI
46#include <acpi/processor.h> 47#include <acpi/processor.h>
@@ -2237,6 +2238,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)
2237 return ret; 2238 return ret;
2238 2239
2239 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; 2240 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY;
2241 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY;
2240 /* This reflects the intel_pstate_get_cpu_pstates() setting. */ 2242 /* This reflects the intel_pstate_get_cpu_pstates() setting. */
2241 policy->cur = policy->cpuinfo.min_freq; 2243 policy->cur = policy->cpuinfo.min_freq;
2242 2244
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 87165f06a307..a5ce0bbeadb5 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -120,6 +120,13 @@ struct cpufreq_policy {
120 bool fast_switch_possible; 120 bool fast_switch_possible;
121 bool fast_switch_enabled; 121 bool fast_switch_enabled;
122 122
123 /*
124 * Preferred average time interval between consecutive invocations of
125 * the driver to set the frequency for this policy. To be set by the
126 * scaling driver (0, which is the default, means no preference).
127 */
128 unsigned int transition_delay_us;
129
123 /* Cached frequency lookup from cpufreq_driver_resolve_freq. */ 130 /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
124 unsigned int cached_target_freq; 131 unsigned int cached_target_freq;
125 int cached_resolved_idx; 132 int cached_resolved_idx;
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index b1fedf9932d6..76877a62b5fa 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -494,7 +494,6 @@ static int sugov_init(struct cpufreq_policy *policy)
494{ 494{
495 struct sugov_policy *sg_policy; 495 struct sugov_policy *sg_policy;
496 struct sugov_tunables *tunables; 496 struct sugov_tunables *tunables;
497 unsigned int lat;
498 int ret = 0; 497 int ret = 0;
499 498
500 /* State should be equivalent to EXIT */ 499 /* State should be equivalent to EXIT */
@@ -533,10 +532,16 @@ static int sugov_init(struct cpufreq_policy *policy)
533 goto stop_kthread; 532 goto stop_kthread;
534 } 533 }
535 534
536 tunables->rate_limit_us = LATENCY_MULTIPLIER; 535 if (policy->transition_delay_us) {
537 lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC; 536 tunables->rate_limit_us = policy->transition_delay_us;
538 if (lat) 537 } else {
539 tunables->rate_limit_us *= lat; 538 unsigned int lat;
539
540 tunables->rate_limit_us = LATENCY_MULTIPLIER;
541 lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
542 if (lat)
543 tunables->rate_limit_us *= lat;
544 }
540 545
541 policy->governor_data = sg_policy; 546 policy->governor_data = sg_policy;
542 sg_policy->tunables = tunables; 547 sg_policy->tunables = tunables;