mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
	io-uring@vger.kernel.org, netdev@vger.kernel.org,
	kernel-team@meta.com, "Paul E. McKenney" <paulmck@kernel.org>,
	Dmitry Ilvokhin <d@ilvokhin.com>, Ingo Molnar <mingo@redhat.com>,
	Will Deacon <will@kernel.org>, Boqun Feng <boqun@kernel.org>,
	Waiman Long <longman@redhat.com>
Subject: [PATCH 08/12] rtmutex: Use accessor for hrtimer_sleeper ->task field
Date: Fri, 18 Sep 2026 17:14:24 -0700	[thread overview]
Message-ID: <20260919001428.3133388-8-paulmck@kernel.org> (raw)
In-Reply-To: <5dca353c-6b3f-4d01-8808-bef2c0dd7af7@paulmck-laptop>

The hrtimer_sleeper structure's ->task field is used as a flag to indicate
that the associated hrtimer has expired.  This means that the hrtimer
handler can be storing to this field while other code is loading from it
to check for expiry.  Note that additional races appear for hrtimers that
can be restarted, which could be argued to be a user error.  However, that
is no reason to let the compiler introduce additional confusion, and to
this end, the hrtimer_sleeper_task_get() was introduced, use of which also
has the benefit of avoiding open-code access to hrtimer_sleeper innards.

Therefore, apply this accessor to rt_mutex_slowlock_block().

KCSAN located this issue.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Dmitry Ilvokhin <d@ilvokhin.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Will Deacon <will@kernel.org>
Cc: Boqun Feng <boqun@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: <linux-aio@kvack.org>
Cc: <linux-fsdevel@vger.kernel.org>
Cc: <io-uring@vger.kernel.org>
Cc: <netdev@vger.kernel.org>
---
 kernel/locking/rtmutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 4728631ae719..5a9534c715b8 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1644,7 +1644,7 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
 			break;
 		}
 
-		if (timeout && !timeout->task) {
+		if (timeout && !hrtimer_sleeper_task_get(timeout)) {
 			ret = -ETIMEDOUT;
 			break;
 		}
-- 
2.40.1


  parent reply	other threads:[~2026-09-19  0:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  0:13 [PATCH v2] Fix data races on " Paul E. McKenney
2026-09-19  0:14 ` [PATCH 01/12] hrtimer: Mark data-racy accesses to " Paul E. McKenney
2026-09-19  0:14 ` [PATCH 02/12] aio: Use accessor for " Paul E. McKenney
2026-09-19  0:14 ` [PATCH 03/12] wait: " Paul E. McKenney
2026-09-19  0:14 ` [PATCH 04/12] io-uring/rw: " Paul E. McKenney
2026-09-19  0:14 ` [PATCH 05/12] futex: Use accessor for hrtimer_sleeper ->task field in waitwake.c Paul E. McKenney
2026-09-19  0:14 ` [PATCH 06/12] timers: Use accessor for hrtimer_sleeper ->task field in sleep_timeout.c Paul E. McKenney
2026-09-19  0:14 ` [PATCH 07/12] net: pktgen: Use accessor for hrtimer_sleeper ->task field Paul E. McKenney
2026-09-19  0:14 ` Paul E. McKenney [this message]
2026-09-19  0:14 ` [PATCH 09/12] futex: Use accessor for hrtimer_sleeper ->task field in requeue Paul E. McKenney
2026-09-19  0:14 ` [PATCH 10/12] hrtimer: Update hrtimer_resolution only if value changes Paul E. McKenney
2026-09-19  0:14 ` [PATCH 11/12] hrtimer: Mark the hrtimer_sleeper structure's ->task field __private Paul E. McKenney
2026-09-19  0:14 ` [PATCH 12/12] hrtimer: Apply READ_ONCE() to lockless base->running loads 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=20260919001428.3133388-8-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=boqun@kernel.org \
    --cc=d@ilvokhin.com \
    --cc=frederic@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=will@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®