From: "Paul E. McKenney" <paulmck@kernel.org>
To: Thomas Gleixner <tglx@kernel.org>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH RFC 1/9] hrtimer: Mark data-racy accesses to hrtimer_sleeper ->task field
Date: Tue, 11 Aug 2026 12:15:51 -0700 [thread overview]
Message-ID: <4d29bdd1-c0a2-4fce-a983-daa7231d04cd@paulmck-laptop> (raw)
In-Reply-To: <87jypwn5k0.ffs@fw13>
On Tue, Aug 11, 2026 at 03:35:27PM +0200, Thomas Gleixner wrote:
> On Thu, Jul 30 2026 at 17:40, Paul E. McKenney wrote:
> > static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer)
> > {
> > struct hrtimer_sleeper *t = container_of(timer, struct hrtimer_sleeper, timer);
> > - struct task_struct *task = t->task;
> > + struct task_struct *task = hrtimer_sleeper_task_get(t);
> >
> > - t->task = NULL;
> > + hrtimer_sleeper_task_set(t, NULL);
>
> To be honest, I find these helper functions more confusing that
> useful unless you make the task member private at the very end of the
> series once everything is converted over.
Good point, and thank you for the reminder. As shown below?
> If not, then what's wrong with a plain READ/WRITE_ONCE()?
Nothing wrong with a good READ_ONCE() or WRITE_ONCE() as far as I am
concerned! ;-)
Thanx, Paul
------------------------------------------------------------------------
commit cff6e1c78dbf97f50d19613266aa22d4b7588e95
Author: Paul E. McKenney <paulmck@kernel.org>
Date: Tue Aug 11 12:11:32 2026 -0700
hrtimer: Mark the hrtimer_sleeper structure's ->task field __private
The hrtimer_sleeper structure's ->task field is now used only by the
hrtimer_sleeper_task_get() and hrtimer_sleeper_task_set() functions,
and there is no reason for it to be directly accessed anywhere else.
Therefore, mark this field __private and use ACCESS_PRIVATE() in
hrtimer_sleeper_task_get() and hrtimer_sleeper_task_set().
Suggested-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 3ad2ab0443af71..5c04423e8e900b 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -73,7 +73,7 @@ enum hrtimer_mode {
*/
struct hrtimer_sleeper {
struct hrtimer timer;
- struct task_struct *task;
+ struct task_struct __private *task;
};
static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
@@ -352,11 +352,11 @@ extern int schedule_hrtimeout_range_clock(ktime_t *expires,
extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);
static inline struct task_struct *hrtimer_sleeper_task_get(struct hrtimer_sleeper *sl)
{
- return READ_ONCE(sl->task);
+ return READ_ONCE(ACCESS_PRIVATE(sl, task));
}
static inline void hrtimer_sleeper_task_set(struct hrtimer_sleeper *sl, struct task_struct *t)
{
- WRITE_ONCE(sl->task, t);
+ WRITE_ONCE(ACCESS_PRIVATE(sl, task), t);
}
/* Soft interrupt function to run the hrtimer queues: */
next prev parent reply other threads:[~2026-08-11 19:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 0:39 [PATCH RFC 0/9] Fix data races on " Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 1/9] hrtimer: Mark data-racy accesses to " Paul E. McKenney
2026-08-04 17:25 ` Dmitry Ilvokhin
2026-08-11 13:35 ` Thomas Gleixner
2026-08-11 19:15 ` Paul E. McKenney [this message]
2026-07-31 0:40 ` [PATCH RFC 2/9] aio: Use accessor for " Paul E. McKenney
2026-07-31 12:32 ` Jan Kara
2026-07-31 12:57 ` Christian Brauner
2026-07-31 17:40 ` Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 3/9] wait: " Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 4/9] io-uring/rw: " Paul E. McKenney
2026-07-31 15:03 ` Jens Axboe
2026-07-31 17:42 ` Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 5/9] futex: Use accessor for hrtimer_sleeper ->task field in waitwake.c Paul E. McKenney
2026-08-03 15:20 ` André Almeida
2026-08-04 17:29 ` Dmitry Ilvokhin
2026-07-31 0:40 ` [PATCH RFC 6/9] timers: Use accessor for hrtimer_sleeper ->task field in sleep_timeout.c Paul E. McKenney
2026-08-04 17:31 ` Dmitry Ilvokhin
2026-07-31 0:40 ` [PATCH RFC 7/9] net: pktgen: Use accessor for hrtimer_sleeper ->task field Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 8/9] rtmutex: " Paul E. McKenney
2026-08-04 17:32 ` Dmitry Ilvokhin
2026-08-04 20:15 ` Paul E. McKenney
2026-07-31 0:40 ` [PATCH RFC 9/9] futex: Use accessor for hrtimer_sleeper ->task field in requeue Paul E. McKenney
2026-08-03 15:21 ` André Almeida
2026-08-03 15:45 ` Paul E. McKenney
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=4d29bdd1-c0a2-4fce-a983-daa7231d04cd@paulmck-laptop \
--to=paulmck@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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®