[tip: timers/nohz] timers/nohz: Mark got_idle_tick accesses as same-CPU races

From: tip-bot2 for Kunwu Chan

Date: Mon Nov 09 2026 - 12:05:04 EST


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

Commit-ID: 109fad8c8a7142b25818e64b9e12aed3935408d9
Gitweb: https://git.kernel.org/tip/109fad8c8a7142b25818e64b9e12aed3935408d9
Author: Kunwu Chan <kunwu.chan@xxxxxxxxx>
AuthorDate: Wed, 07 Oct 2026 10:28:59 +08:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Mon, 09 Nov 2026 17:50:54 +01:00

timers/nohz: Mark got_idle_tick accesses as same-CPU races

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>
Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Link: https://patch.msgid.link/20261007022859.60101-3-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 5e96c2e..2554883 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)
@@ -1264,8 +1264,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;