[tip: timers/nohz] tick/nohz: Reset got_idle_tick when entering dynticks idle

From: tip-bot2 for Marco Crivellari

Date: Fri Dec 04 2026 - 16:19:33 EST


The following commit has been merged into the timers/nohz branch of tip:

Commit-ID: beac8262102498a431f44d463e5bb365db6fd345
Gitweb: https://git.kernel.org/tip/beac8262102498a431f44d463e5bb365db6fd345
Author: Marco Crivellari <marco.crivellari@xxxxxxxx>
AuthorDate: Thu, 12 Nov 2026 17:38:12 +01:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Fri, 04 Dec 2026 22:12:44 +01:00

tick/nohz: Reset got_idle_tick when entering dynticks idle

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>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Tested-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Link: https://patch.msgid.link/20261112163813.524336-5-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 8eb2c25..dbc70b2 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();