mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] locking/rtmutex: priority inheritance fixes and tests
@ 2026-11-08 14:13 Mathieu Desnoyers
  2026-11-08 14:13 ` [PATCH v2 1/5] locking/rtmutex: Stop spinning on the owner when the waiter is woken Mathieu Desnoyers
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Mathieu Desnoyers @ 2026-11-08 14:13 UTC (permalink / raw)
  To: peterz, tglx, mingo
  Cc: linux-kernel, Mathieu Desnoyers, will, boqun, longman, rostedt,
	bigeasy, clrkwllms, dvhart, dave, andrealmeid, shuah, juri.lelli,
	linux-rt-devel, linux-kselftest

Hi Peter, Thomas,

This series fixes three rt_mutex priority inheritance bugs on v7.4-rc1,
and adds two tests that catch them. The bugs came out of the work on
"sched/deadline: bandwidth accounting fixes and selftests". Its v5,
posted after this series, applies on top of it. Its patch 8 takes a
deadline boost from the waiter's rt_mutex node, and needs patch 3 here
to keep that node current.

The fixes
=========

 1  Stop spinning on a running owner once the waiter is woken, so that
    timeouts and signals are no longer delayed.
 2  Initialize the ww_mutex context of a waiter, so that PREEMPT_RT
    reports PI futex deadlocks again.
 3  Clone a waiter's sort keys as it enters pi_waiters, so that the
    owner inherits the right priority.

Patch 4 adds futex_lock_pi_inherit to the futex selftests. It checks the
priority an owner runs at, and the EDEADLK of FUTEX_LOCK_PI. It also
checks how late a timeout or a signal ends a wait behind a running
owner. Patch 5 adds an ABBA with both owners running to test-ww_mutex.
v7.4-rc1 fails the cases of each fix. The series passes them, with and
without PREEMPT_RT. So do the locking API selftests, the ww_mutex
selftest, locktorture's rtmutex_lock and the futex selftests.

How this was developed
======================

An LLM coding assistant wrote these patches, their messages and the
tests, under my direction and review. Patch 1 came out of a stress test
of the deadline boost. Patch 3 came out of a review of the deadline fix
by a second model. Patch 2 came out of futex_lock_pi_inherit, on its
first run with PREEMPT_RT. A local run of the Sashiko AI review checked
each patch before posting.

Changes since v1
================

- Commit messages and comments rewritten to read more easily, after
  Peter's and Steven's reviews.
- Patch 1: Steven's wording, with the two paragraphs on the impact
  added. It carries his Reviewed-by.
- Patch 3: new subject, "locking/rtmutex: Clone the sort keys in
  rt_mutex_enqueue_pi()". The message shows the sequence that leaves
  stale keys, and the comment is one line.
- Patch 5: the stage handoff of the ABBA test uses release and acquire,
  as the Sashiko review of v1 found. On a weakly ordered CPU, the test
  could fail falsely with EDEADLK.
- No change to the kernel code.

Based on v7.4-rc1, 6628e7d4c6b2. It also applies as is to tip
sched/urgent (006991aa8997), which the deadline series is based on.

v1: https://lore.kernel.org/lkml/20261106235931.1478800-1-mathieu.desnoyers@efficios.com

Mathieu Desnoyers (5):
  locking/rtmutex: Stop spinning on the owner when the waiter is woken
  locking/rtmutex: Initialize the ww_mutex context of a waiter
  locking/rtmutex: Clone the sort keys in rt_mutex_enqueue_pi()
  selftests/futex: Test priority inheritance on PI futexes
  locking/ww_mutex/test: Time an ABBA with both owners running

 kernel/locking/rtmutex.c                      |   9 +-
 kernel/locking/rtmutex_common.h               |   1 +
 kernel/locking/test-ww_mutex.c                | 235 ++++++
 .../selftests/futex/functional/.gitignore     |   1 +
 .../selftests/futex/functional/Makefile       |   3 +-
 .../futex/functional/futex_lock_pi_inherit.c  | 773 ++++++++++++++++++
 .../testing/selftests/futex/functional/run.sh |   3 +
 7 files changed, 1021 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/futex/functional/futex_lock_pi_inherit.c


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.47.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-08 14:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 14:13 [PATCH v2 0/5] locking/rtmutex: priority inheritance fixes and tests Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 1/5] locking/rtmutex: Stop spinning on the owner when the waiter is woken Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 2/5] locking/rtmutex: Initialize the ww_mutex context of a waiter Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 3/5] locking/rtmutex: Clone the sort keys in rt_mutex_enqueue_pi() Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 4/5] selftests/futex: Test priority inheritance on PI futexes Mathieu Desnoyers
2026-11-08 14:13 ` [PATCH v2 5/5] locking/ww_mutex/test: Time an ABBA with both owners running Mathieu Desnoyers

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®