Files
linux/include/linux
Sebastian Andrzej Siewior 912edebe85 futex: Provide rt_mutex_.*_schedule() equivalents for futex scheduling
There is rt_mutex_{pre|post}_schedule() around
rt_mutex_wait_proxy_lock() to ensure that sched_submit_work()/
sched_update_worker() is invoked before we schedule out and block on
rt_mutex while waiting for it become available.

The reason is that blocking on rt_mutex assigns a pi_waiter for the PI
chain and sched_submit_work() will also assign a pi_waiter if it blocks
on lock but a this point we already have a waiter assigned.
We can't skip sched_submit_work() entirely because I/O relies on the
fact that I/O queue is flushed while it blocks on a sleeping lock.
Therefore sched_submit_work() is moved before we block on the lock.

Sleeping lock in this context means mutex or rw_semaphore not spinlock_t
on PREEMPT_RT. Because the mutex abstraction on PREEMPT_RT uses the same
abstraction as the futex proxy lock, the futex code ended up using
rt_mutex_{pre|post}_schedule(), too.
Using it is/ was just to keep the task_struct::sched_rt_mutex assertion
happy. Futex proxy lock is used only in the syscall context of a task.
At this point it never got any I/O that needs to be flushed and it can't
be a workqueue that needs to notify that it will be scheduled out.
Therefore sched_submit_work() does nothing here.

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.

Adding rt_mutex_pre_schedule() here looks wrong (as noted by PeterZ)
because at this point there is a pi_waiter recorded and invoking
sched_submit_work() with a possible lock contention would be wrong.

Add rt_mutex_futex_{pre|post}_schedule() which toggles the
sched_rt_mutex assert and does not involve sched_submit_work(). Add
asserts here to ensure that sched_submit_work() would do nothing. Use it
only in futex proxy lock case which is rt_mutex_wait_proxy_lock().
Remove it from futex_lock_pi().

Fixes: d14f9e930b ("locking/rtmutex: Use rt_mutex specific scheduler helpers")
Reported-by: Yao Kai <yaokai34@huawei.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260901135453.3121948-2-bigeasy@linutronix.de
Closes: https://lore.kernel.org/all/20260717084922.4153317-2-yaokai34@huawei.com
2026-09-04 08:14:15 +02:00
..
2026-07-23 10:24:12 -07:00
2026-08-07 14:18:13 -03:00
2026-04-02 15:52:49 +02:00
2026-05-21 13:04:42 +02:00
2026-03-19 23:55:27 +01:00
2026-05-28 21:24:54 -07:00
2026-08-10 18:00:47 +01:00
2026-07-29 17:54:58 -07:00
2026-08-04 19:18:48 -07:00
2026-04-03 16:53:50 -04:00
2026-08-15 17:09:32 -06:00
2026-08-15 23:36:18 +02:00
2026-06-07 10:03:01 -07:00
2026-07-27 16:25:34 +02:00
2026-08-06 06:47:33 -06:00
2026-07-07 15:10:48 -04:00
2026-05-28 17:45:46 -07:00
2026-06-05 00:34:55 -04:00
2026-05-18 11:16:29 +02:00
2026-05-28 11:36:59 -04:00
2026-02-27 16:40:16 +01:00
2026-06-05 17:46:17 -07:00
2026-05-28 21:24:43 -07:00
2026-04-05 13:53:28 -07:00
2026-04-01 10:19:41 +02:00
2026-07-31 10:09:12 +02:00
2026-04-03 16:53:50 -04:00
2026-03-18 09:59:57 +00:00
2026-03-08 11:06:53 +01:00
2026-07-23 15:42:48 +02:00
2026-08-12 16:24:26 +02:00
2026-06-26 22:18:34 -04:00
2026-07-28 21:11:47 -07:00
2026-04-05 13:53:10 -07:00
2026-04-20 11:35:17 -07:00
2026-08-05 11:20:12 -07:00
2026-08-05 11:20:12 -07:00
2026-07-23 19:21:13 +01:00
2026-03-08 11:06:53 +01:00
2026-03-31 07:04:00 -06:00
2026-08-15 23:36:18 +02:00
2026-07-15 15:34:25 -07:00
2026-07-15 15:34:25 -07:00
2026-07-27 17:18:00 +02:00
2026-03-13 08:22:54 +01:00
2026-05-11 16:59:43 +02:00
2026-03-12 15:05:34 +01:00
2026-07-31 16:22:52 -04:00
2026-06-06 15:22:44 +02:00