From: Christian Loehle <christian.loehle@arm.com>
To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
rafael@kernel.org, viresh.kumar@linaro.org, mingo@redhat.com,
peterz@infradead.org, vincent.guittot@linaro.org,
daniel.lezcano@kernel.org
Cc: anna-maria@linutronix.de, frederic@kernel.org,
tglx@linutronix.de, dietmar.eggemann@arm.com, jstultz@google.com,
qyousef@layalina.io, hongyan.xia@transsion.com,
sibi.sankar@oss.qualcomm.com, lukasz.luba@arm.com,
morten.rasmussen@arm.com
Subject: Re: [PATCH] sched/cpufreq: Reevaluate frequency before tickless idle
Date: Mon, 24 Aug 2026 15:07:54 +0100 [thread overview]
Message-ID: <a4da085b-5a42-4559-a677-3796acd65170@arm.com> (raw)
In-Reply-To: <20260824131842.2443385-1-christian.loehle@arm.com>
On 8/24/26 14:18, Christian Loehle wrote:
> sugov_hold_freq() can preserve a UCLAMP_MIN-driven high frequency when
> the runqueue goes idle. If cpuidle then stops the tick, no later
> utilization update is guaranteed and a CPU using WFI can remain at an
> unnecessarily high voltage for the entire idle period.
>
> Issue a final cpufreq update when the idle tick actually transitions to
> stopped and force single-policy schedutil past its rate limit. Keep the
> existing hold behavior when the tick is retained.
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
> ---
> include/linux/sched/cpufreq.h | 1 +
> kernel/sched/cpufreq_schedutil.c | 5 ++++-
> kernel/sched/idle.c | 29 +++++++++++++++++++++++++++--
> 3 files changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h
> index bdd31ab93bc5..0814f6c79315 100644
> --- a/include/linux/sched/cpufreq.h
> +++ b/include/linux/sched/cpufreq.h
> @@ -9,6 +9,7 @@
> */
>
> #define SCHED_CPUFREQ_IOWAIT (1U << 0)
> +#define SCHED_CPUFREQ_IDLE (1U << 1)
>
> #ifdef CONFIG_CPU_FREQ
> struct cpufreq_policy;
> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index a1782755efcc..90bf8d8bffb7 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -100,7 +100,7 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
>
> return true;
> } else if (sg_policy->need_freq_update) {
> - /* ignore_dl_rate_limit() wants a new frequency to be found. */
> + /* A forced update needs a new frequency to be found. */
> return true;
> }
>
> @@ -407,6 +407,9 @@ static inline bool sugov_update_single_common(struct sugov_cpu *sg_cpu,
> sugov_iowait_boost(sg_cpu, time, flags);
> sg_cpu->last_update = time;
>
> + if (flags & SCHED_CPUFREQ_IDLE)
> + sg_cpu->sg_policy->need_freq_update = true;
> +
> ignore_dl_rate_limit(sg_cpu);
>
> if (!sugov_should_update_freq(sg_cpu->sg_policy, time))
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index eb73b65ce6c4..36f8840d0562 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -161,10 +161,35 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> return cpuidle_enter(drv, dev, next_state);
> }
>
> +static void idle_stop_tick(void)
> +{
> +#ifdef CONFIG_CPU_FREQ
> + bool was_stopped = tick_nohz_tick_stopped();
> +#endif
> +
> + tick_nohz_idle_stop_tick();
> +
> +#ifdef CONFIG_CPU_FREQ
> + /*
> + * Run one last cpufreq update before entering idle with the tick
> + * stopped, because no later update is guaranteed.
> + */
> + if (!was_stopped && tick_nohz_tick_stopped()) {
> + struct rq *rq = this_rq();
> + struct rq_flags rf;
> +
> + rq_lock(rq, &rf);
> + update_rq_clock(rq);
> + cpufreq_update_util(rq, SCHED_CPUFREQ_IDLE);
Sashiko correctly noted that this may lead to an infinite loop on
slow-switch platforms where the pre-idle update results in another
sugov kthread wakeup which in turn will result in a new pre-idle
cpufreq update.
I will just track if sugov actually held a frequency and gate
the update on that in v2.
next prev parent reply other threads:[~2026-08-24 14:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:18 Christian Loehle
2026-08-24 14:07 ` Christian Loehle [this message]
2026-08-25 2:51 ` Hongyan Xia
2026-08-25 9:00 ` Christian Loehle
2026-08-25 12:52 ` Vincent Guittot
2026-08-25 17:58 ` Christian Loehle
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=a4da085b-5a42-4559-a677-3796acd65170@arm.com \
--to=christian.loehle@arm.com \
--cc=anna-maria@linutronix.de \
--cc=daniel.lezcano@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=hongyan.xia@transsion.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rafael@kernel.org \
--cc=sibi.sankar@oss.qualcomm.com \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
/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®