Re: [PATCH v3 2/2] cpufreq: fix policy max not returning to non-boost freq on boost disable
From: Pierre Gondois
Date: Fri Nov 20 2026 - 07:08:49 EST
Hello Viresh, Ananthu:
On 11/19/26 05:49, Viresh Kumar wrote:
On 18-11-26, 17:59, Ananthu C V wrote:Sorry for the wall of text:
This does fix the issue of policy->max not being able to drop down backPierre, any inputs ?
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 veryThere are two issues the series is trying to address;
sure how you are reaching to this issue over current mainline (without
the first patch).
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.
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.