Re: [PATCH v3 2/2] cpufreq: fix policy max not returning to non-boost freq on boost disable
From: Pierre Gondois
Date: Mon Nov 23 2026 - 11:32:57 EST
On 11/23/26 11:22, Ananthu C V wrote:
Hi Pierre,
On Fri, Nov 20, 2026 at 01:08:01PM +0100, Pierre Gondois wrote:
Hello Viresh, Ananthu:[snip]
Sorry for the wall of text:Thanks, cpuinfo.max_freq not actually being very clear about what value it
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.
contains is precisely one of the reasons why this approach was taken.
------------Right, that makes more sense. My original idea was to not go trough separate
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.
iterations when freq_table.c already does that, but it makes sense to just
keep it entirely seperate and avoid further calculations of the same. As you
said, the values should be constant anyway, and once calculated they should
stay the same.
------------I take it that (correct me if I am wrong) this generally means we don't
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;
want to go implementing solutions for this in every driver and instead
should let the core itself handle this (which is what the current series
is trying to do)? A maintainer call on which route to go will definitely
help in focusing the attention there. ACK on simplifying the interaction
with cpufreq_frequency_table_cpuinfo().
IMO yes, the condition above which seems to be only here for the
acpi-cpufreq driver could be handled in the generic code in
policy_set_boost(). The max available freq. could then be obtained
with:
unsigned long get_max_freq(struct cpufreq_policy *policy)
{
return policy->boost_enabled ?
policy->cpuinfo.max_boost_freq :
policy->cpuinfo.max_base_freq;
}
instead of storing different values in policy->cpuinfo.max_freq,
which seems to be made to describe a CPU capabilities.
This would also allow to remove the responsibility to set
cpuinfo.max_freq in the .set_boost() callbacks and factorize it.
B. The new CPPC spec [1]The idea was exactly this when I went this route of calculating these
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].
values separately. The previous revision was doing precisely this,
by adding a cpuinfo.max_table_freq field (fun fact, the initial name I
has was max_boost_freq itself, which I later changed to max_table_freq
because not everything is always boost capable :p). But the general
consensus was that, including the reviews from Rafael, we don't need a
new field added to track this value. And even for the max_base_freq
field the current revision is using, the general opinion seems to be
that we don't necessarily need such a field. Now, I am personally of the
opinion that adding these two fields (and calculating and storing them
once as you already mentioned) will make the calculations infinitely
simpler. What route should we really go?
I also agree, but also Rafael pointed out that this could work without
new fields [1]. Maybe there will be new elements in this thread
and the direction will change (or not).
[1] https://lore.kernel.org/all/CAJZ5v0i_QYa-LcrK1U1VZjZZiJ3d-9hPbMdBbaGoqMds0BAU6w@xxxxxxxxxxxxxx/
The new CPPC nominal freq. should always be lower than the initialThat sounds like a good enhancement, but I'd prefer to work on that later
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.
once the current issues are solved, these are bugs causing some decent
damage afterall. But LMK if having that also is quite important at this
point.
------------Thanks a lot for being detailed, Pierre. The direction I have taken for
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.
this series is exactly this, sans the additional qos request for the max
base freq. As you have pointed out, the current goal is to get at least
the bugs fixed. So having the maintainers make a call on what is the
direction we want to take in general will be a lot of help. What do you
all think, Viresh, Rafael, and Pierre?
Best,
Ananthu