Message ID | 20231027080400.56703-4-vincent.guittot@linaro.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | consolidate and cleanup CPU capacity | expand |
Context | Check | Description |
---|---|---|
conchuod/vmtest-for-next-PR | fail | PR summary |
conchuod/patch-3-test-1 | fail | .github/scripts/patches/build_rv32_defconfig.sh |
conchuod/patch-3-test-2 | fail | .github/scripts/patches/build_rv64_clang_allmodconfig.sh |
conchuod/patch-3-test-3 | fail | .github/scripts/patches/build_rv64_gcc_allmodconfig.sh |
conchuod/patch-3-test-4 | fail | .github/scripts/patches/build_rv64_nommu_k210_defconfig.sh |
conchuod/patch-3-test-5 | fail | .github/scripts/patches/build_rv64_nommu_virt_defconfig.sh |
conchuod/patch-3-test-6 | success | .github/scripts/patches/checkpatch.sh |
conchuod/patch-3-test-7 | success | .github/scripts/patches/dtb_warn_rv64.sh |
conchuod/patch-3-test-8 | success | .github/scripts/patches/header_inline.sh |
conchuod/patch-3-test-9 | success | .github/scripts/patches/kdoc.sh |
conchuod/patch-3-test-10 | success | .github/scripts/patches/module_param.sh |
conchuod/patch-3-test-11 | success | .github/scripts/patches/verify_fixes.sh |
conchuod/patch-3-test-12 | success | .github/scripts/patches/verify_signedoff.sh |
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 458d359f5991..f3a87fa16332 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -114,6 +114,28 @@ static void sugov_deferred_update(struct sugov_policy *sg_policy) } } +/** + * get_capacity_ref_freq - get the reference frequency that has been used to + * correlate frequency and compute capacity for a given cpufreq policy. We use + * the CPU managing it for the arch_scale_freq_ref() call in the function. + * @policy: the cpufreq policy of the CPU in question. + * + * Return: the reference CPU frequency to compute a capacity. + */ +static __always_inline +unsigned long get_capacity_ref_freq(struct cpufreq_policy *policy) +{ + unsigned int freq = arch_scale_freq_ref(policy->cpu); + + if (freq) + return freq; + + if (arch_scale_freq_invariant()) + return policy->cpuinfo.max_freq; + + return policy->cur; +} + /** * get_next_freq - Compute a new frequency for a given cpufreq policy. * @sg_policy: schedutil policy object to compute the new frequency for. @@ -140,10 +162,10 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, unsigned long util, unsigned long max) { struct cpufreq_policy *policy = sg_policy->policy; - unsigned int freq = arch_scale_freq_invariant() ? - policy->cpuinfo.max_freq : policy->cur; + unsigned int freq; util = map_util_perf(util); + freq = get_capacity_ref_freq(policy); freq = map_util_freq(util, freq, max); if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)