Re: [PATCH] sched/fair: Only apply cpufreq pressure where frequency is invariant
From: Vincent Guittot
Date: Fri Aug 21 2026 - 05:27:48 EST
On Fri, 21 Aug 2026 at 09:43, Jianyong Wu <wujianyong@xxxxxxxx> wrote:
>
> cpufreq pressure lowers a CPU's capacity by the ratio between the highest
> frequency it may reach and the highest one it can reach right now.
> Utilization carries the matching scaling only where the architecture is
> frequency invariant; without it a fully busy CPU accumulates the whole
> SCHED_CAPACITY_SCALE whatever frequency it runs at.
>
> Reducing capacity on such a system scales one side of the comparison and
> not the other, and a fully busy CPU ends up reporting more utilization
> than it is credited with being able to run.
Even with frequency invariance, utilization can exceed capacity, only
the time to reach it will change.
What issue do you try to fix?
>
> This became reachable with commit d2d5c129d07e ("cpufreq: Make
> cpufreq_update_pressure() fall back to cpuinfo.max_freq"); before it the
> pressure was always zero there. Whether that matters depends on frequency
> invariance rather than on the fallback itself: a system that has it scales
> both sides and is unaffected, while a system that does not scales only the
> capacity.
>
> Fixes: d2d5c129d07e ("cpufreq: Make cpufreq_update_pressure() fall back to cpuinfo.max_freq")
> Signed-off-by: Jianyong Wu <wujianyong@xxxxxxxx>
> ---
> kernel/sched/fair.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index c19a025d8d68..a163e00c9882 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5854,10 +5854,17 @@ static inline void util_est_dequeue(struct cfs_rq *cfs_rq,
> static inline unsigned long get_actual_cpu_capacity(int cpu)
> {
> unsigned long capacity = arch_scale_cpu_capacity(cpu);
> + unsigned long pressure = hw_load_avg(cpu_rq(cpu));
>
> - capacity -= max(hw_load_avg(cpu_rq(cpu)), cpufreq_get_pressure(cpu));
> + /*
> + * Utilization only follows frequency where the architecture is
> + * frequency invariant. Elsewhere, lowering the capacity would
> + * scale one side of the comparison and not the other.
> + */
> + if (arch_scale_freq_invariant())
> + pressure = max(pressure, cpufreq_get_pressure(cpu));
>
> - return capacity;
> + return capacity - pressure;
> }
>
> static inline int util_fits_cpu(unsigned long util,
> --
> 2.34.1
>
>