Re: [PATCH v6 3/4] cpufreq: Set policy->min and max as real QoS constraints

From: Pierre Gondois

Date: Tue Mar 24 2026 - 07:49:02 EST



On 3/20/26 11:14, Viresh Kumar wrote:
On 17-03-26, 11:17, Pierre Gondois wrote:
cpufreq_set_policy() will ultimately override the policy min/max
values written in the .init() callback through:
cpufreq_policy_online()
\-cpufreq_init_policy()
\-cpufreq_set_policy()
\-/* Set policy->min/max */
Thus the policy min/max values provided are only temporary.
I am not comfortable with this patch to be honest. policy->min/max are used at
so many places that it is really difficult to make sure if this patch will break
something or not.

For example:

cpufreq_set_policy()
cpufreq_driver->verify()
cpufreq_frequency_table_verify()

This uses min/max before it is set by the path you mentioned.

I would suggest dropping this change, or most of it and doing only what is
really required for this series.

Being able to set the min/max_freq_req from the driver might be
something that is needed, cf:
https://lore.kernel.org/lkml/20260213100633.15413-1-zhangpengjie2@xxxxxxxxxx/

It would also allow to have a common way to set policy->min/max values
as they are set to the the cpuinfo.min/max_freq.

On the other hand I agree that I didn't test all the possible paths
for this change, so this is a bit audacious.


What about adding the following to have the values set for all drivers:

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c

index 70814c567243b..3a1e5f58a301f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1530,6 +1530,9 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
                                CPUFREQ_CREATE_POLICY, policy);
        }

+       policy->max = policy->cpuinfo.max_freq;
+       policy->min = policy->cpuinfo.min_freq;
+
        if (cpufreq_driver->get && has_target()) {
                policy->cur = cpufreq_driver->get(policy->cpu);
                if (!policy->cur) {