diff options
author | Vincent Guittot <vincent.guittot@linaro.org> | 2023-08-31 08:54:21 +0200 |
---|---|---|
committer | Vincent Guittot <vincent.guittot@linaro.org> | 2023-08-31 09:57:11 +0200 |
commit | c5038495d9bbb5a3ac80438c128a7ef03b3b392b (patch) | |
tree | d05529b55d5a1aabbc4977ef96e5713166875097 | |
parent | 5d4ebc6d1bc3cf7e7b0d14b97c5f47eb567e1c05 (diff) |
cpufreq/schedutil: use a fixed reference frequency
cpuinfo_max_freq can change at runtime because of boost as example. This
implies that the value could not the same that has been used when
computing the capacity of a CPU.
a new arch_scale_freq_ref() is available to return the fixed and coherent
frequency reference that can be used when computing a frequency based on an
utilization. Use it when available.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
-rw-r--r-- | kernel/sched/cpufreq_schedutil.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4492608b7d7f..9996ef429e2b 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -114,6 +114,31 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy) } } +#ifdef arch_scale_freq_ref +/** + * arch_scale_freq_ref_policy - get the reference frequency of a given CPU that + * has been used to correlate frequency and compute capacity. + * @cpu: the CPU in question. + * + * Return: the reference CPU frequency. + */ +static __always_inline +unsigned long arch_scale_freq_ref_policy(struct cpufreq_policy *policy) +{ + return arch_scale_freq_ref(policy->cpu); +} +#else +static __always_inline +unsigned long arch_scale_freq_ref_policy(struct cpufreq_policy *policy) +{ + if (arch_scale_freq_invariant()) + return policy->cpuinfo.max_freq; + + + return policy->cur; +} +#endif + /** * get_next_freq - Compute a new frequency for a given cpufreq policy. * @sg_policy: schedutil policy object to compute the new frequency for. @@ -139,11 +164,11 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy) static unsigned int get_next_freq(struct sugov_policy *sg_policy, unsigned long util, unsigned long max) { + unsigned int freq; struct cpufreq_policy *policy = sg_policy->policy; - unsigned int freq = arch_scale_freq_invariant() ? - policy->cpuinfo.max_freq : policy->cur; util = map_util_perf(util); + freq = arch_scale_freq_ref_policy(policy); freq = map_util_freq(util, freq, max); if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) |