From: Christian Loehle <christian.loehle@arm.com>
To: Navon John Lukose <navonjohnlukose@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpuidle: teo: Keep the tick when intercepts predict a short idle period
Date: Wed, 2 Dec 2026 12:37:32 +0000 [thread overview]
Message-ID: <6d47fcee-f243-419e-9326-788cc90eeb2c@arm.com> (raw)
In-Reply-To: <20261202082511.1475746-1-navonjohnlukose@gmail.com>
On 12/2/26 08:25, Navon John Lukose wrote:
> When the intercepts metrics make teo_select() pick a state shallower
> than the sleep length allows, the idle duration is expected to be below
> the target residency of the deeper state that was rejected. Whether or
> not to stop the tick is still decided from the sleep length though, so
> if the expected wakeup does not come, the CPU stays in the shallow state
> with the tick stopped until the next timer. Before commit 21d28cd2fa5f
> ("cpuidle: teo: Do not call tick_nohz_get_sleep_length() upfront") the
> middle of the selected state's bin was used as the expected idle
> duration in that case, which kept the tick for shallow states.
>
> Cap duration_ns at the target residency of the shallowest state
> rejected because of intercepts before using it for the tick decision.
>
> On an Arrow Lake-H laptop (HZ=1000, intel_idle _CST states C1/C2/C3
> with target residencies of 1/381/3144 us), idle with the display off,
> psys power drops from 2.23 W to 1.16 W and package C10 residency rises
> from 38% to 57%. Over five loads waking a task every 1.5-3 ms, psys
> drops by 0.86 W on average, and for cross-CPU pipe wakeups every
> 1.5-2 ms the p90 wakeup latency rises by 15-19 us.
>
> Fixes: 21d28cd2fa5f ("cpuidle: teo: Do not call tick_nohz_get_sleep_length() upfront")
> Signed-off-by: Navon John Lukose <navonjohnlukose@gmail.com>
> ---
> Measured with teo.c built as a module on 7.3, stock and patched, in 8
> interleaved 100 s idle rounds and 6 interleaved rounds of each periodic
> load. menu gets 1.25 W and 67% PC10 at idle on the same machine.
>
> C1 residencies longer than one tick go from 522-1398 to 1-4 per minute.
> C2 can still be entered with the tick stopped, because C3's target
> residency is above one tick and the pre-6.6 code stopped the tick there
> as well. That is where the remaining PC10 gap to menu comes from (PC6
> 16% vs 2%).
Hi,
thanks for the patch, I think it makes sense.
Do you mind just dumping the state counts / duration deltas, IMO that
would be more readable.
>
> drivers/cpuidle/governors/teo.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
> index 735894a1a7f..b8b8b58468c 100644
> --- a/drivers/cpuidle/governors/teo.c
> +++ b/drivers/cpuidle/governors/teo.c
> @@ -319,6 +319,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> int intercept_max_idx = -1;
> int constraint_idx = 0;
> int idx0 = 0, idx = -1;
> + s64 intercept_ns = KTIME_MAX;
> s64 duration_ns;
> int i;
>
> @@ -419,6 +420,8 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> if (dev->states_usage[i].disable)
> continue;
>
> + /* State idx is rejected, so expect a shorter idle duration. */
> + intercept_ns = drv->states[idx].target_residency_ns;
> idx = i;
> if (2 * intercept_sum > idx_intercept_sum &&
> i <= intercept_max_idx)
> @@ -500,6 +503,15 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
> return idx;
> }
>
> + /*
> + * If the candidate state has been selected because of intercepts, the
> + * idle duration is expected to be below the target residency of the
> + * shallowest state rejected for this reason, so use that value instead
> + * of the sleep length when deciding whether or not to stop the tick.
> + */
> + if (duration_ns > intercept_ns)
> + duration_ns = intercept_ns;
I did propose something in that direction too, but didn't follow up on it:
https://lore.kernel.org/lkml/20240606090050.327614-3-christian.loehle@arm.com/
> +
> if (!idx)
> goto out_tick;
>
prev parent reply other threads:[~2026-12-02 12:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 8:25 Navon John Lukose
2026-12-02 12:37 ` Christian Loehle [this message]
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=6d47fcee-f243-419e-9326-788cc90eeb2c@arm.com \
--to=christian.loehle@arm.com \
--cc=daniel.lezcano@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=navonjohnlukose@gmail.com \
--cc=rafael@kernel.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®