mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ananthu C V <ananthu.cv@oss.qualcomm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
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>,
	Pierre Gondois <pierre.gondois@arm.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: Wed, 18 Nov 2026 17:59:09 +0530	[thread overview]
Message-ID: <av2aFWw3kh11U68A@hu-anancv-blr.qualcomm.com> (raw)
In-Reply-To: <avwtsmp7Mqacbbtl@vireshk-B250M-D3H>

On Tue, Nov 17, 2026 at 04:04:26PM +0530, Viresh Kumar wrote:
> On 11-11-26, 18:10, Ananthu C V wrote: 
> > I am pretty sure we can maintain the policy->min status quo and only touch the
> > policy->max updation; which from a passing glance simply seems inconsequential.
> > Potential side effects, if any, aside, this would at least fix the issue at
> > hand, which is the frequency getting stuck on a higher value without being able
> > to come down. What do you think about this?
> 
> So a change like this also fixes the issue ?
> 
> @@ -49,15 +49,16 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy)
>                         max_freq = freq;
>         }
> 
>         policy->cpuinfo.min_freq = min_freq;
> +       policy->max = max_freq;
>         /*
>          * 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;
> +               policy->max = policy->cpuinfo.max_freq = max_freq;

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.

> -- 
> viresh

Best,
Ananthu

  reply	other threads:[~2026-11-18 12:29 UTC|newest]

Thread overview: 18+ 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 [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=av2aFWw3kh11U68A@hu-anancv-blr.qualcomm.com \
    --to=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=pierre.gondois@arm.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®