From: Kunwu Chan <kunwu.chan@gmail.com>
To: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org,
mingo@kernel.org, tglx@kernel.org
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
Kunwu Chan <kunwu.chan@gmail.com>
Subject: [PATCH v2 2/2] timers/nohz: Mark got_idle_tick accesses as same-CPU races
Date: Fri, 2 Oct 2026 23:17:56 +0800 [thread overview]
Message-ID: <20261002151757.3605081-3-kunwu.chan@gmail.com> (raw)
In-Reply-To: <20261002151757.3605081-1-kunwu.chan@gmail.com>
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@kernel.org>
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
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 a7893a079a83..eb6065c8a90d 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)
@@ -1246,8 +1246,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
prev parent reply other threads:[~2026-10-02 15:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 15:17 [PATCH v2 0/2] rwonce: Introduce {READ,WRITE}_ONCE_THIS_CPU() Kunwu Chan
2026-10-02 15:17 ` [PATCH v2 1/2] rwonce: Add READ_ONCE_THIS_CPU() and WRITE_ONCE_THIS_CPU() Kunwu Chan
2026-10-02 15:44 ` Paul E. McKenney
2026-10-02 15:17 ` Kunwu Chan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261002151757.3605081-3-kunwu.chan@gmail.com \
--to=kunwu.chan@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=frederic@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®