mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpuidle: teo: Keep the tick when intercepts predict a short idle period
@ 2026-12-02  8:25 Navon John Lukose
  2026-12-02 12:37 ` Christian Loehle
  0 siblings, 1 reply; 3+ messages in thread
From: Navon John Lukose @ 2026-12-02  8:25 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano
  Cc: Christian Loehle, linux-pm, linux-kernel

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%).

 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;
+
 	if (!idx)
 		goto out_tick;
 
-- 
2.56.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02  8:25 [PATCH] cpuidle: teo: Keep the tick when intercepts predict a short idle period Navon John Lukose
2026-12-02 12:37 ` Christian Loehle
2026-12-02 14:55   ` Navon John Lukose

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®