[PATCH v3 2/2] timers/nohz: Mark got_idle_tick accesses as same-CPU races

From: Kunwu Chan

Date: Tue Oct 06 2026 - 22:30:12 EST


got_idle_tick is a per-CPU flag set by the tick interrupt handler in
tick_sched_do_timer() and read and cleared by the idle path in
tick_nohz_idle_got_tick(). The flag is intentionally accessed without
ordering or locking; a concurrent set can be overwritten by the clear.

Use WRITE_ONCE_THIS_CPU() and READ_ONCE_THIS_CPU() to identify these
as intentional races between execution contexts on the same CPU,
rather than accesses that may race across CPUs.

Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
kernel/time/tick-sched.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6c3fea386..a136bb247 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -269,7 +269,7 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
}

if (tick_sched_flag_test(ts, TS_FLAG_INIDLE))
- ts->got_idle_tick = 1;
+ WRITE_ONCE_THIS_CPU(ts->got_idle_tick, 1);
}

static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
@@ -1248,8 +1248,8 @@ bool tick_nohz_idle_got_tick(void)
{
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);

- if (ts->got_idle_tick) {
- ts->got_idle_tick = 0;
+ if (READ_ONCE_THIS_CPU(ts->got_idle_tick)) {
+ WRITE_ONCE_THIS_CPU(ts->got_idle_tick, 0);
return true;
}
return false;
--
2.43.0