Re: [PATCH] sched/fair: Only apply cpufreq pressure where frequency is invariant

From: Hongyan Xia

Date: Wed Sep 09 2026 - 00:09:55 EST


On 9/7/2026 4:37 PM, K Prateek Nayak wrote:
> On 9/7/2026 1:37 PM, K Prateek Nayak wrote:
>> So, I've been trying to understand these bits and looking at
>> cpufreq_policy_init_qos(), the "policy->cpuinfo.max_freq" should be the
>> frequency including the boost range but I see cpufreq_update_pressure()
>> and it says:
>>
>> max_freq = arch_scale_freq_ref(cpu);
>> if (!max_freq)
>> max_freq = policy->cpuinfo.max_freq;
>>
>> capped_freq = policy->max;
>>
>> /*
>> * Handle properly the boost frequencies, which should simply clean
>> * the cpufreq pressure value.
>> */
>> if (max_freq <= capped_freq) {
>> ...
>> }
>>
>>
>> Looking at this, I feel "policy->cpuinfo.max_freq" should not include
>> the boost frequency, or x86 should implement a arch_scale_freq_ref()
>> to know when boost is enabled vs disabled.
>>
>> If cpufreq_update_pressure() indeed has to disregard boost frequency,
>> and anything above P0 is not considered as pressure, we can simply
>> do:
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index b898b6544069..068e6d6e15a1 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -2586,8 +2586,11 @@ static void cpufreq_update_pressure(struct cpufreq_policy *policy)
>>
>> cpu = cpumask_first(policy->related_cpus);
>> max_freq = arch_scale_freq_ref(cpu);
>> - if (!max_freq)
>> - max_freq = policy->cpuinfo.max_freq;
>> + if (!max_freq) {
>> + max_freq = __resolve_freq(policy, policy->cpuinfo.max_freq,
>> + policy->max, policy->min,
>
> My bad, that should have been other way around and use the cpuinfo
> fields to prevent capping based on policy limits. Updated diff:
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index b898b6544069..97f4a3ba5107 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2586,8 +2586,11 @@ static void cpufreq_update_pressure(struct cpufreq_policy *policy)
>
> cpu = cpumask_first(policy->related_cpus);
> max_freq = arch_scale_freq_ref(cpu);
> - if (!max_freq)
> - max_freq = policy->cpuinfo.max_freq;
> + if (!max_freq) {
> + max_freq = __resolve_freq(policy, policy->cpuinfo.max_freq,
> + policy->cpuinfo.min_freq, policy->cpuinfo.max_freq,
> + CPUFREQ_RELATION_H);
> + }
>
> capped_freq = policy->max;
>

LGTM.

NIT: I do wonder if we need a full __resolve_freq() each time. We could
cache the highest achievable OPP on max_freq updates, but that's future
optimization.

> ---
> [...]