From: Mario Limonciello <mario.limonciello@amd.com>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>,
Jianyong Wu <wujianyong@hygon.cn>
Cc: viresh.kumar@linaro.org, kprateek.nayak@amd.com,
vincent.guittot@linaro.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, ray.huang@amd.com,
perry.yuan@amd.com, zhanjie9@hisilicon.com,
zhenglifeng1@huawei.com, pierre.gondois@arm.com,
sumitg@nvidia.com, srinivas.pandruvada@linux.intel.com,
hongyan.xia@transsion.com, zhongqiu.han@oss.qualcomm.com,
jianyong.wu@outlook.com, wangfengyu@hygon.cn, zhongyuan@hygon.cn,
huangsj@hygon.cn,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Subject: Re: [PATCH] cpufreq: Use a non-boost reference frequency for pressure calculation
Date: Thu, 17 Sep 2026 13:34:22 -0500 [thread overview]
Message-ID: <a92b1050-5f67-463c-977a-87af9682656d@amd.com> (raw)
In-Reply-To: <CAJZ5v0g2d6fY8hM0FVH8tiOUhXm0PZM+Qn7OxM9YNXm8i0pYmg@mail.gmail.com>
On 9/17/26 12:38, Rafael J. Wysocki (Intel) wrote:
> On Tue, Sep 15, 2026 at 9:03 AM Jianyong Wu <wujianyong@hygon.cn> wrote:
>>
>> Commit d2d5c129d07e ("cpufreq: Make cpufreq_update_pressure() fall
>> back to cpuinfo.max_freq") introduced cpuinfo.max_freq as the reference
>> frequency for cpufreq pressure when arch_scale_freq_ref() returns zero.
>>
>> However, cpuinfo.max_freq may include boost frequencies and therefore
>> does not necessarily represent the maximum sustainable frequency.
>
> And then it really matters what is sustainable and for how long.
>
>> On some systems using acpi-cpufreq, cpuinfo.max_freq includes boost while
>> the frequency table only contains non-boost frequencies.
>
> In which case selecting freq_table[0] may give the processor a license
> to go to the turbo (or boost) frequency range.
>
>> Consequently, cpufreq pressure remains nonzero even without an additional
>> frequency limit.
>
> So when and where does this matter?
>
>> Furthermore, drivers may update cpuinfo.max_freq when boost is enabled
>> or disabled. With a fixed policy limit below the maximum non-boost
>> frequency, this changes the pressure reference and hence the reported
>> pressure, although the non-boost frequency limit remains unchanged.
>
> If the capacity is updated though along with the cpuinfo.max_freq
> change, then this is all fine because the pressure is then computed
> relative to the new capacity. intel_pstate does that.
>
>> Add max_sustainable_freq to struct cpufreq_cpuinfo to provide a reference
>> frequency excluding boost. Populate it from the nominal frequency in
>> amd-pstate and cppc_cpufreq, the maximum non-turbo frequency in
>> intel_pstate, and the highest frequency-table entry in acpi-cpufreq.
>>
>> Use this value when arch_scale_freq_ref() returns zero. Preserve the
>> existing cpuinfo.max_freq fallback for drivers that leave the new field
>> at zero.
>>
>> Tested with acpi-cpufreq, intel_pstate, and amd-pstate in active and
>> passive modes. With no additional frequency limit, pressure is zero.
>> With a fixed limit below the non-boost reference frequency, pressure
>> remains unchanged across boost transitions.
>
> Which may not be what is intended.
>
>> Fixes: d2d5c129d07e ("cpufreq: Make cpufreq_update_pressure() fall back to cpuinfo.max_freq")
>> Signed-off-by: Jianyong Wu <wujianyong@hygon.cn>
>> ---
>> The earlier fix was incorrect and has been abandoned. This patch takes
>> a different approach.
>>
>> Previous discussion: https://lore.kernel.org/all/SI2PR04MB4931A8BA0EF213B0238BD9E4E3BD2@SI2PR04MB4931.apcprd04.prod.outlook.com/
>>
>> drivers/cpufreq/acpi-cpufreq.c | 3 +++
>> drivers/cpufreq/amd-pstate.c | 2 ++
>> drivers/cpufreq/cppc_cpufreq.c | 3 ++-
>> drivers/cpufreq/cpufreq.c | 4 +++-
>> drivers/cpufreq/intel_pstate.c | 2 ++
>> include/linux/cpufreq.h | 2 ++
>> 6 files changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 21639d9ac753..e7b22456ebb8 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -856,6 +856,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
>> }
>> freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
>>
>> + /* Init max sustainable cpu frequency */
>> + policy->cpuinfo.max_sustainable_freq = freq_table[0].frequency;
>> +
Maybe I'm missing something, but it sounds to me like it would make
sense to just:
policy->cpuinfo.nominal_freq = freq_table[0].frequency
and then use cpuinfo.nominal_freq everywhere, no?
>> max_boost_ratio = get_max_boost_ratio(cpu, &nominal_freq);
>> if (max_boost_ratio) {
>> unsigned int freq = nominal_freq;
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index 3a6b4b224a66..6fc28bb1499b 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -1085,6 +1085,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>> perf.lowest_perf);
>> policy->cpuinfo.max_freq = cpudata->max_freq;
>>
>> + policy->cpuinfo.max_sustainable_freq = cpudata->nominal_freq;
>> policy->driver_data = cpudata;
>> ret = amd_pstate_cppc_enable(policy);
>> if (ret)
>> @@ -1912,6 +1913,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>> policy->cpuinfo.min_freq = perf_to_freq(perf, cpudata->nominal_freq,
>> perf.lowest_perf);
>> policy->cpuinfo.max_freq = cpudata->max_freq;
>> + policy->cpuinfo.max_sustainable_freq = cpudata->nominal_freq;
>> policy->driver_data = cpudata;
>>
>> ret = amd_pstate_cppc_enable(policy);
>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
>> index 6fe0e972952a..f803fcdca483 100644
>> --- a/drivers/cpufreq/cppc_cpufreq.c
>> +++ b/drivers/cpufreq/cppc_cpufreq.c
>> @@ -682,7 +682,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
>> policy->cpuinfo.min_freq = cppc_perf_to_khz(caps, caps->lowest_perf);
>> policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, policy->boost_enabled ?
>> caps->highest_perf : caps->nominal_perf);
>> -
>> + policy->cpuinfo.max_sustainable_freq =
>> + cppc_perf_to_khz(caps, caps->nominal_perf);
>> policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu);
>> policy->shared_type = cpu_data->shared_type;
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index b898b6544069..c1d54a22265d 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -2587,7 +2587,9 @@ 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;
>> + max_freq = policy->cpuinfo.max_sustainable_freq ?
>> + policy->cpuinfo.max_sustainable_freq :
>> + policy->cpuinfo.max_freq;
>>
>> capped_freq = policy->max;
>>
>> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
>> index 6e984c114d96..daef7e99fead 100644
>> --- a/drivers/cpufreq/intel_pstate.c
>> +++ b/drivers/cpufreq/intel_pstate.c
>> @@ -1474,6 +1474,7 @@ static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy,
>>
>> policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
>> cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
>> + policy->cpuinfo.max_sustainable_freq = cpudata->pstate.max_freq;
>>
>> refresh_frequency_limits(policy);
>> }
>> @@ -3052,6 +3053,7 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
>> policy->cpuinfo.min_freq = cpu->pstate.min_freq;
>> policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
>> cpu->pstate.max_freq : cpu->pstate.turbo_freq;
>> + policy->cpuinfo.max_sustainable_freq = cpu->pstate.max_freq;
>>
>> intel_pstate_init_acpi_perf_limits(policy);
>>
>> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
>> index ae9d1ce4f49c..aa3f60a167be 100644
>> --- a/include/linux/cpufreq.h
>> +++ b/include/linux/cpufreq.h
>> @@ -45,6 +45,8 @@ enum cpufreq_table_sorting {
>> struct cpufreq_cpuinfo {
>> unsigned int max_freq;
>> unsigned int min_freq;
>> + /* Maximum sustainable frequency excluding boost, or 0 if unknown. */
>> + unsigned int max_sustainable_freq;
>>
>> /* in 10^(-9) s = nanoseconds */
>> unsigned int transition_latency;
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2026-09-17 18:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 6:57 Jianyong Wu
2026-09-15 9:32 ` Hongyan Xia
2026-09-15 12:46 ` Jianyong Wu
2026-09-17 17:38 ` Rafael J. Wysocki (Intel)
2026-09-17 18:34 ` Mario Limonciello [this message]
2026-09-18 5:59 ` Jianyong Wu
2026-09-18 4:08 ` Jianyong Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a92b1050-5f67-463c-977a-87af9682656d@amd.com \
--to=mario.limonciello@amd.com \
--cc=hongyan.xia@transsion.com \
--cc=huangsj@hygon.cn \
--cc=jianyong.wu@outlook.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=perry.yuan@amd.com \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sumitg@nvidia.com \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
--cc=wangfengyu@hygon.cn \
--cc=wujianyong@hygon.cn \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
--cc=zhongqiu.han@oss.qualcomm.com \
--cc=zhongyuan@hygon.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®