From: Pierre Gondois <pierre.gondois@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
Ananthu C V <ananthu.cv@oss.qualcomm.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
Sudeep Holla <sudeep.holla@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Jie Zhan <zhanjie9@hisilicon.com>,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
linux-pm@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Oleg Keri <okerixx@gmail.com>
Subject: Re: [PATCH v3 2/2] cpufreq: fix policy max not returning to non-boost freq on boost disable
Date: Fri, 20 Nov 2026 13:08:01 +0100 [thread overview]
Message-ID: <6d6a84bf-29bd-47c7-9243-ab0b9e2d7f32@arm.com> (raw)
In-Reply-To: <av5_zDI4bg28H_6e@vireshk-B250M-D3H>
Hello Viresh, Ananthu:
On 11/19/26 05:49, Viresh Kumar wrote:
> On 18-11-26, 17:59, Ananthu C V wrote:
>> This does fix the issue of policy->max not being able to drop down back
>> to non-boost values after boost disable, but I found another caveat.
>>
>> The commit 8c83947c5dbb added the following change a few months ago;
>>
>> static int cpufreq_policy_init_qos(struct cpufreq_policy *policy)
>> {
>> + unsigned int min_freq, max_freq;
>> int ret;
>>
>> + /* Use policy->min/max set by the driver as QoS requests. */
>> + min_freq = max(FREQ_QOS_MIN_DEFAULT_VALUE, policy->min);
>> + if (policy->max)
>> + max_freq = min(FREQ_QOS_MAX_DEFAULT_VALUE, policy->max);
>> + else
>> + max_freq = FREQ_QOS_MAX_DEFAULT_VALUE;
>>
>> this max_freq is then subsequently used to update max_freq_req constraint
>> for the policy. This means, assigning a value to policy max in freq table
>> directly will cause the same to be kept as the max_freq_req, which if
>> boost is not enabled will be stuck at a non-boost value. The boost will
>> still work, as policy max is set directly, but the value will be above
>> the allowed qos max;
>>
>> # echo 1 > ../boost
>> cpufreq: cpufreq: policy12 boost=1 policy->max=4723200 qos_max=4454400
>> cpufreq: cpufreq: policy6 boost=1 policy->max=4723200 qos_max=4454400
>>
>> This also means if at any later point any limit refresh happens, the
>> value will be brought back to that qos max, which is a non-boost value,
>> even when boost is enabled;
>>
>> (e.g. here with a refresh_frequency_limits(policy); call after the boost)
>>
>> # echo 1 > ../boost
>> cpufreq: cpufreq: policy12 boost=1 policy->max=4454400 qos_max=4454400
>> cpufreq: cpufreq: policy6 boost=1 policy->max=4454400 qos_max=4454400
>>
>> tldr; is that it will fix the issue of the freq not dropping down from
>> boost, but it will introduce a new potential problem of boost state
>> potentially dropping back to non-boost freq while still in boost.
>>
>> So this alone can't be a fix at the very least. At the bare minimum it
>> will need update to how max_freq_req is calculated/updated, etc. If
>> nobody assigns values to policy->max before cpufreq_policy_init_qos
>> is called, max_freq_req can simply use FREQ_QOS_MAX_DEFAULT_VALUE,
>> which is S32_MAX, as its value, and not cause this problem, so the
>> solution proposed in the current series will not run into this.
>>
>>> Also, can you please explain the issue again in detail. I am not very
>>> sure how you are reaching to this issue over current mainline (without
>>> the first patch).
>> There are two issues the series is trying to address;
>> 1. freq can go upto boost values, but they cannot be actually used
>> 2. once a policy is using a boost value, that value cannot go back to a
>> non boost value.
>>
>> So with or without patch 1, which addresses the first issue, the freq
>> can still go to boost values, which can trigger the second issue. The
>> logs relevant to the second issue, reusing from the cover letter, is;
>>
>> \# cd /sys/devices/system/cpu/cpufreq/
>> \# ls
>> boost policy0 policy12 policy6
>> \# cat boost
>> 0
>> \# cat policy6/scaling_max_freq
>> 4454400
>> \# echo 1 > boost
>> \# cat policy6/scaling_max_freq
>> 4723200
>> \# echo 0 > boost
>> \# cat policy6/scaling_max_freq
>> 472320
>>
>> The reason why this is happening is;
>>
>> from freq_table.c:
>>
>> if (policy->cpuinfo.max_freq < max_freq)
>> policy->cpuinfo.max_freq = max_freq;
>>
>> and from cpufreq.c:
>>
>> freq_qos_update_request(&policy->boost_freq_req, policy->cpuinfo.max_freq);
>>
>> so cpuinfo.max_freq is only updated upwards, and that value is used to update
>> boost_freq_req, which is a FREQ_QOS_MAX request. On boost enable and disable
>> the cpuinfo.max_freq value stuck at the top will be used to update the qos
>> max, and the value never comes down.
> Pierre, any inputs ?
Sorry for the wall of text:
cpuinfo.max_freq is used for various purposes. This patchset corrects
some bugs, but ideally the usage of cpuinfo.max_freq should be clearer.
cpuinfo.max_freq is used as:
The max hardware freq.:
- cpufreq_schedutil.c::get_capacity_ref_freq()
- arch_topology.c::init_cpu_capacity_callback()
- cpufreq.c::cpufreq_get_hw_max_freq()
- intel_llc::cpu_max_MHz()
- windfarm_cpufreq_clamp.c()::wf_cpufreq_clamp_init
The max boost/non-boost freq. (i.e. without the user-set constraint):
- processor_thermal.c::cpufreq_update_thermal_limit()
- cpufreq_ondemand.c::od_update()
- cpufreq.c::policy_set_boost()
- cpufreq.c::cpufreq_update_pressure()
cpuinfo.max_freq value depends on the presence/absence of boost. It is
thus hard to know what the field actually contains, and:
- PATCH 1 adds cpufreq_frequency_table_max() to get the actual boosted
max freq.
- PATCH 2 allows to retrieve the actual non-boosted max freq.
are trying to rationalize that.
------------
The following frequencies:
- max hardware (boosted) freq.
- max non-boosted freq. (i.e. nominal freq.)
are CPU/platform specific values that can be computed at init() and
which will not change merely because boost is enabled or disabled
The existing. set_boost() callback implementations are mostly
retrieving these values to update cpuinfo.max_freq, but this could be
done from the main framework if we stored these values (in cpuinfo for
instance). Similar remark for cpufreq_frequency_table_cpuinfo().
It seems there is a lot of code to re-compute/update these values even
though they should not change. Computing them and storing them once
should be possible I think.
------------
A. acpi-cpufreq driver
3c55e94c0ade "cpufreq: ACPI: Extend frequency tables to cover boost
frequencies" added a synthetic entry in the freq. table to represent
the max boosted freq. as read from CPPC. Entries in the freq. table are
otherwise fetched from _PSS entries.
538b0188da46 "cpufreq: ACPI: Set cpuinfo.max_freq directly if max boost"
is known removed the synthetic freq. which was added in the freq. table
as it reported the synthetic freq. to userspace which was apparently
confusing.
PATCH 2 "cpufreq: fix policy max not returning to non-boost freq on
boost disable" modifies cpufreq_frequency_table_cpuinfo() to handle
this case, but maybe it would be easier to tag/flag the case where
the max boosted freq. is not in the freq. table and handle this case
separately. Doing the following for all drivers makes things
complicated IMO.
```
/*
* If the driver has set its own cpuinfo.max_freq above max_freq, leave
* it as is.
*/
if (policy->cpuinfo.max_freq < max_freq)
policy->cpuinfo.max_freq = max_freq;
```
B. The new CPPC spec [1]
The nominal freq. will be writeable in the future, so some additional
synchronization will be required.
------------
This patchset adds a cpuinfomax_base_freq field. Maybe we should also
add a cpuinfo.max_boost_freq field to make it clearer when someone
wants to get the max hardware freq. If we find a way to know when
cpuinfo.max_boost_freq is a synthetic value, this would allow to
solve [A].
The new CPPC nominal freq. should always be lower than the initial
ospm_nominal_freq field [1]. So an additional (struct freq_qos_request)
for the nominal (i.e. max_base_freq) frequency might be nice to have
aswell.
------------
Short summary:
The patchset should fix the bugs, but IMO it is still not really clear
which max freq. is stored cpuinfo.max_freq.
I think we would benefit from also:
- adding a cpuinfo.max_boost_freq
- adding a (struct freq_qos_request) for the nominal freq.
- use cpuinfo.max_[base|boost]_freq wherever needed, to simplify
the .set_boost() callbacks for instance.
but this might be out of scope if the goal is just to fix the bugs.
next prev parent reply other threads:[~2026-11-20 12:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 11:38 [PATCH v3 0/2] sched/cpufreq: fix schedutil's boost frequency handling Ananthu C V
2026-09-29 11:38 ` [PATCH v3 1/2] arch_topology: seed capacity_freq_ref with highest available frequency Ananthu C V
2026-10-11 14:16 ` Zhongqiu Han
2026-10-12 18:45 ` Dietmar Eggemann
2026-10-13 11:28 ` Zhongqiu Han
2026-11-11 12:10 ` Ananthu C V
2026-11-11 12:12 ` Ananthu C V
2026-09-29 11:38 ` [PATCH v3 2/2] cpufreq: fix policy max not returning to non-boost freq on boost disable Ananthu C V
2026-10-11 14:17 ` Zhongqiu Han
2026-11-11 12:21 ` Ananthu C V
2026-11-11 13:47 ` Zhongqiu Han
2026-10-11 23:42 ` Dietmar Eggemann
2026-11-11 12:27 ` Ananthu C V
2026-11-02 8:38 ` Viresh Kumar
2026-11-11 12:40 ` Ananthu C V
2026-11-17 10:34 ` Viresh Kumar
2026-11-18 12:29 ` Ananthu C V
2026-11-19 4:49 ` Viresh Kumar
2026-11-20 12:08 ` Pierre Gondois [this message]
2026-09-30 9:10 ` [PATCH v3 0/2] sched/cpufreq: fix schedutil's boost frequency handling Oleg Keri
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=6d6a84bf-29bd-47c7-9243-ab0b9e2d7f32@arm.com \
--to=pierre.gondois@arm.com \
--cc=ananthu.cv@oss.qualcomm.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=okerixx@gmail.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
/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®