[PATCH v3 4/5] tick/nohz: Reset got_idle_tick when entering dynticks idle

From: Marco Crivellari

Date: Thu Nov 12 2026 - 11:41:48 EST


A tick firing after the last tick_nohz_idle_got_tick() and before
tick_nohz_idle_exit() leaves got_idle_tick set, and the next
cpuidle_idle_call() then assumes that a later dynticks idle period was
ended by the tick. Now that the CPU leaves dynticks idle before polling,
this can also happen within a single idle trip when it switches between
cpuidle and polling, e.g. when it polls because the tick broadcast has
expired.

Reset got_idle_tick when entering dynticks idle, so that it only reports
the ticks of the current period.

Suggested-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Signed-off-by: Marco Crivellari <marco.crivellari@xxxxxxxx>
---
kernel/time/tick-sched.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index b4149f40b5f1..fb47d5dfbf4e 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1237,6 +1237,8 @@ void tick_nohz_idle_enter(void)
if (tick_sched_flag_test(ts, TS_FLAG_INIDLE))
return;

+ /* Only report the ticks of this dynticks idle period */
+ ts->got_idle_tick = 0;
WARN_ON_ONCE(ts->timer_expires_base);
tick_sched_flag_set(ts, TS_FLAG_INIDLE);
ts->idle_entrytime = ktime_get();
--
2.56.0