From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Borislav Petkov" <bp@alien8.de>, "Yao Kai" <yaokai34@huawei.com>
Subject: Re: [PATCH v4 1/2] futex: Provide rt_mutex_.*_schedule() equivalents for futex scheduling
Date: Tue, 1 Sep 2026 15:56:33 +0200 [thread overview]
Message-ID: <20260901135633.wBOUP152@linutronix.de> (raw)
In-Reply-To: <20260901135453.3121948-2-bigeasy@linutronix.de>
On 2026-09-01 15:54:51 [+0200], To linux-kernel@vger.kernel.org wrote:
> By mistake futex_wait_requeue_pi() -> rt_mutex_wait_proxy_lock() did not
> get the rt_mutex_{pre|post}_schedule() annotation. This was not noticed
> because in this callchain the lock is (usually) not contended and so
> rt_mutex_slowlock_block() does not schedule, triggering the assert.
The following makes it trigger more reliably.
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 4728631ae7194..15037c35c684f 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1633,13 +1633,14 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
struct rt_mutex *rtm = container_of(lock, struct rt_mutex, rtmutex);
struct task_struct *owner;
int ret = 0;
+ int first_loop = 1;
__assume_ctx_lock(&rtm->rtmutex.wait_lock);
lockevent_inc(rtmutex_slow_block);
for (;;) {
/* Try to acquire the lock: */
- if (try_to_take_rt_mutex(lock, current, waiter)) {
+ if (!first_loop && try_to_take_rt_mutex(lock, current, waiter)) {
lockevent_inc(rtmutex_slow_acq3);
break;
}
@@ -1665,7 +1666,11 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
owner = NULL;
raw_spin_unlock_irq_wake(&lock->wait_lock, wake_q);
- if (!owner || !rtmutex_spin_on_owner(lock, waiter, owner)) {
+ if (first_loop || !owner || !rtmutex_spin_on_owner(lock, waiter, owner)) {
+ if (first_loop) {
+ first_loop = 0;
+ __set_current_state(TASK_RUNNING);
+ }
lockevent_inc(rtmutex_slow_sleep);
rt_mutex_schedule();
}
Sebastian
next prev parent reply other threads:[~2026-09-01 13:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 13:54 [PATCH v4 0/2] futex: Address two futex-requeue-pi issues Sebastian Andrzej Siewior
2026-09-01 13:54 ` [PATCH v4 1/2] futex: Provide rt_mutex_.*_schedule() equivalents for futex scheduling Sebastian Andrzej Siewior
2026-09-01 13:56 ` Sebastian Andrzej Siewior [this message]
2026-09-04 6:15 ` [tip: locking/urgent] " tip-bot2 for Sebastian Andrzej Siewior
2026-09-01 13:54 ` [PATCH v4 2/2] futex: Prevent rcuwait use-after-free during requeue PI Sebastian Andrzej Siewior
2026-09-04 6:15 ` [tip: locking/urgent] " tip-bot2 for Yao Kai
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=20260901135633.wBOUP152@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=andrealmeid@igalia.com \
--cc=bp@alien8.de \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=yaokai34@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.