Skip to content

locking, sched: The PREEMPT-RT locking infrastructure

Thomas Gleixner lkml 4 versions – Applied

Status from this message: The following commit has been merged into the locking/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest72 patches 10 repliesApplied
  2. v468 patches 1 replySuperseded
  3. v364 patches 14 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v163 patches28 repliesSuperseded

Changes in v5 from the cover letter

- A few lockdep wait_type fixes in static and runtime initializers. Sebastian noticed while working on getting the lockdep selftests reenabled on RT.

- Missing might_sleep() invocations in RT spin/rwlocks (Sebastian)

- Add explicit owner init for local locks when lockdep is enabled instead of relying on zero initialized memory.

- Add the RT variants for local locks, which is the last lock type getting special treatment on RT.

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/72locking/local_lock: Add missing owner initializationinclude/linux/local_lock_internal.h+23 -190 replies
2/72locking/rtmutex: Set proper wait context for lockdepinclude/linux/rtmutex.h kernel/locking/rtmutex.c+13 -80 replies
3/72sched: Split out the wakeup state checkkernel/sched/core.c+18 -60 replies
4/72sched: Introduce TASK_RTLOCK_WAITinclude/linux/sched.h+3 -10 replies
5/72sched: Reorganize current::__state helpersinclude/linux/sched.h+23 -250 replies
6/72sched: Prepare for RT sleeping spin/rwlocksinclude/linux/sched.h kernel/sched/core.c+99 -00 replies
7/72sched: Rework the __schedule() preempt argumentkernel/sched/core.c+23 -110 replies
8/72sched: Provide schedule point for RT locksinclude/linux/sched.h kernel/sched/core.c+22 -10 replies
9/72sched/wake_q: Provide WAKE_Q_HEAD_INITIALIZERinclude/linux/sched/wake_q.h+5 -20 replies
10/72media/atomisp: Use lockdep instead of *mutex_is_locked()drivers/staging/media/atomisp/pci/atomisp_ioctl.c+2 -20 replies
11/72rtmutex: Remove rt_mutex_is_locked()include/linux/rtmutex.h+0 -110 replies
12/72rtmutex: Convert macros to inlineskernel/locking/rtmutex.c+27 -40 replies
13/72rtmutex: Switch to try_cmpxchg()kernel/locking/rtmutex.c+2 -20 replies
14/72rtmutex: Split API and implementationkernel/locking/Makefile kernel/locking/rtmutex.c kernel/locking/rtmutex_api.c +1 more+514 -4980 replies
15/72rtmutex: Split out the inner parts of struct rtmutexinclude/linux/rtmutex.h kernel/futex.c kernel/locking/rtmutex.c +3 more+97 -790 replies
16/72locking/rtmutex: Provide rt_mutex_slowlock_locked()kernel/locking/rtmutex.c kernel/locking/rtmutex_api.c+59 -430 replies
17/72rtmutex: Provide rt_mutex_base_is_locked()include/linux/rtmutex.h+12 -00 replies
18/72locking: Add base code for RT rw_semaphore and rwlockinclude/linux/rwbase_rt.h kernel/locking/rwbase_rt.c+301 -01 reply
19/72locking/rwsem: Add rtmutex based R/W semaphore implementationinclude/linux/rwsem.h kernel/locking/rwsem.c+176 -100 replies
20/72locking/rtmutex: Add wake_state to rt_mutex_waiterkernel/locking/rtmutex.c kernel/locking/rtmutex_common.h+10 -10 replies
21/72locking/rtmutex: Provide rt_wake_q and helperskernel/locking/rtmutex.c kernel/locking/rtmutex_common.h+29 -00 replies
22/72locking/rtmutex: Use rt_mutex_wake_q_headkernel/futex.c kernel/locking/rtmutex.c kernel/locking/rtmutex_api.c +1 more+20 -230 replies
23/72locking/rtmutex: Prepare RT rt_mutex_wake_q for RT locksinclude/linux/sched/wake_q.h kernel/locking/rtmutex.c kernel/locking/rtmutex_common.h+20 -40 replies
24/72locking/rtmutex: Guard regular sleeping locks specific functionskernel/locking/rtmutex.c kernel/locking/rtmutex_api.c kernel/locking/rwsem.c+133 -1230 replies
25/72locking/spinlock: Split the lock types headerinclude/linux/rwlock_types.h include/linux/spinlock.h include/linux/spinlock_types.h +1 more+74 -580 replies
26/72locking/rtmutex: Prevent future include recursion hellinclude/linux/rtmutex.h+1 -10 replies
27/72locking/lockdep: Reduce includes in debug_locks.hinclude/linux/debug_locks.h+1 -20 replies
28/72rbtree: Split out the rbtree type definitionsinclude/linux/rbtree.h include/linux/rbtree_types.h+35 -290 replies
29/72locking/rtmutex: Include only rbtree typesinclude/linux/rtmutex.h+1 -10 replies
30/72locking/spinlock: Provide RT specific spinlock typeinclude/linux/spinlock_types.h+26 -00 replies
31/72locking/spinlock: Provide RT variant headerinclude/linux/spinlock.h include/linux/spinlock_api_smp.h include/linux/spinlock_rt.h+162 -10 replies
32/72locking/rtmutex: Provide the spin/rwlock core lock functionkernel/locking/rtmutex.c kernel/locking/rtmutex_common.h+61 -12 replies
33/72locking/spinlock: Provide RT variantkernel/locking/Makefile kernel/locking/spinlock_rt.c+130 -00 replies
34/72locking/rwlock: Provide RT variantinclude/linux/rwlock_rt.h include/linux/rwlock_types.h include/linux/spinlock_rt.h +4 more+323 -132 replies
35/72locking/rtmutex: Squash !RT tasks to DEFAULT_PRIOkernel/locking/rtmutex.c+20 -50 replies
36/72locking/mutex: Consolidate core headerskernel/locking/mutex-debug.c kernel/locking/mutex-debug.h kernel/locking/mutex.c +1 more+25 -510 replies
37/72locking/mutex: Move waiter to core headerinclude/linux/mutex.h kernel/locking/mutex.h+13 -130 replies
38/72locking/ww_mutex: Move ww_mutex declarations into ww_mutex.hinclude/linux/mutex.h include/linux/ww_mutex.h+8 -110 replies
39/72locking/mutex: Make mutex::wait_lock rawinclude/linux/mutex.h kernel/locking/mutex.c+13 -130 replies
40/72locking/ww_mutex: Simplify lockdep annotationkernel/locking/mutex.c+10 -90 replies
41/72locking/ww_mutex: Gather mutex_waiter initializationkernel/locking/mutex-debug.c kernel/locking/mutex.c+4 -98 replies
42/72locking/ww_mutex: Split up ww_mutex_unlock()kernel/locking/mutex.c+13 -130 replies
43/72locking/ww_mutex: Split W/W implementation logickernel/locking/mutex.c kernel/locking/ww_mutex.h+370 -3690 replies
44/72locking/ww_mutex: Remove __sched annotationkernel/locking/ww_mutex.h+6 -60 replies
45/72locking/ww_mutex: Abstract waiter iterationkernel/locking/ww_mutex.h+53 -40 replies
46/72locking/ww_mutex: Abstract waiter enqueueingkernel/locking/ww_mutex.h+13 -60 replies
47/72locking/ww_mutex: Abstract mutex accessorskernel/locking/ww_mutex.h+14 -20 replies
48/72locking/ww_mutex: Abstract mutex typeskernel/locking/ww_mutex.h+13 -100 replies
49/72locking/ww_mutex: Abstract internal lock accessinclude/linux/ww_mutex.h kernel/locking/ww_mutex.h+28 -80 replies
50/72locking/ww_mutex: Implement rt_mutex accessorskernel/locking/ww_mutex.h+80 -00 replies
51/72locking/ww_mutex: Add RT priority to W/W orderkernel/locking/ww_mutex.h+49 -150 replies
52/72locking/ww_mutex: Add rt_mutex based lock type and accessorsinclude/linux/ww_mutex.h kernel/locking/ww_mutex.h+27 -120 replies
53/72locking/rtmutex: Extend the rtmutex core to support ww_mutexkernel/locking/rtmutex.c kernel/locking/rtmutex_api.c kernel/locking/rtmutex_common.h +1 more+114 -130 replies
54/72locking/ww_mutex: Implement rtmutex based ww_mutex API functionskernel/locking/Makefile kernel/locking/ww_rt_mutex.c+77 -10 replies
55/72locking/rtmutex: Add mutex variant for RTinclude/linux/mutex.h kernel/locking/mutex.c kernel/locking/rtmutex_api.c +1 more+187 -160 replies
56/72lib/test_lockup: Adapt to changed variables.lib/test_lockup.c+4 -40 replies
57/72futex: Validate waiter correctly in futex_proxy_trylock_atomic()kernel/futex.c+7 -00 replies
58/72futex: Cleanup stale commentskernel/futex.c+7 -110 replies
59/72futex: Clarify futex_requeue() PI handlingkernel/futex.c+23 -380 replies
60/72futex: Remove bogus condition for requeue PIkernel/futex.c+1 -10 replies
61/72futex: Correct the number of requeued waiters for PIkernel/futex.c+4 -00 replies
62/72futex: Restructure futex_requeue()kernel/futex.c+41 -490 replies
63/72futex: Clarify comment in futex_requeue()kernel/futex.c+20 -80 replies
64/72futex: Reorder sanity checks in futex_requeue()kernel/futex.c+7 -70 replies
65/72futex: Simplify handle_early_requeue_pi_wakeup()kernel/futex.c+23 -270 replies
66/72futex: Prevent requeue_pi() lock nesting issue on RTkernel/futex.c+259 -490 replies
67/72rtmutex: Prevent lockdep false positive with PI futexeskernel/locking/rtmutex_api.c+12 -00 replies
68/72preempt: Adjust PREEMPT_LOCK_OFFSET for RTinclude/linux/preempt.h+4 -00 replies
69/72locking/rtmutex: Implement equal priority lock stealingkernel/locking/rtmutex.c+35 -170 replies
70/72locking/rtmutex: Add adaptive spinwait mechanismkernel/locking/rtmutex.c+65 -20 replies
71/72locking/spinlock/rt: Prepare for RT local_lockinclude/linux/spinlock_rt.h include/linux/spinlock_types.h include/linux/spinlock_types_raw.h +1 more+35 -100 replies
72/72locking/local_lock: Add PREEMPT_RT supportinclude/linux/local_lock_internal.h+48 -00 replies

Reviews trailers per patch

None of the 72 patches has a Reviewed-by or Acked-by.

PatchGregory Haskins
1/72
2/72
3/72
4/72
5/72
6/72
7/72
8/72
9/72
10/72
11/72
12/72
13/72
14/72
15/72
16/72
17/72
18/72
19/72
20/72
21/72
22/72
23/72
24/72
25/72
26/72
27/72
28/72
29/72
30/72
31/72
32/72
33/72
34/72
35/72
36/72
37/72
38/72
39/72
40/72
41/72
42/72
43/72
44/72
45/72
46/72
47/72
48/72
49/72
50/72
51/72
52/72
53/72
54/72
55/72
56/72
57/72
58/72
59/72
60/72
61/72
62/72
63/72
64/72
65/72
66/72
67/72
68/72
69/72
70/72Originally-by
71/72
72/72

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [patch V5 00/72] locking, sched: The PREEMPT-RT locking infrastructure

Folks,

the following series is an update to V4 which can be found here:

https://lore.kernel.org/r/[email protected]

It contains the bulk of the PREEMPT-RT locking infrastructure. In PREEMPT-RT enabled kernels the following locking primitives are substituted by RT-Mutex based variants:

mutex, ww_mutex, rw_semaphore, spinlock, rwlock

semaphores are not substituted because they do not provide strict owner semantics.

Of course raw_spinlocks are not touched either as they protect low level operations in the scheduler, timers and hardware access.

The most interesting parts of the series which need a lot of eyeballs are:

- the scheduler bits which provide the infrastructure for spinlock and rwlock substitution to ensure that the task state is preserved when blocking on such a lock and a regular wakeup is handled correctly and not lost

- the rtmutex core implementation to handle lock contention on spinlocks and rwlocks correctly vs. the task state

- the rw_semaphore/rwlock substitutions which utilize the same implementation vs. the reader/writer handling

- The new rtmutex based ww_mutex implementation.

- the PI futex related bits to handle the interaction between blocking on the underlying rtmutex and contention on the hash bucket lock which is converted to a 'sleeping spinlock'.

The rest surely needs a thorough review as well, but those parts are pretty straight forward: quite some code restructuring and the actual wrapper functions to replace the existing !RT implementations.

The series survived internal testing in RT kernels and is part of the upcoming v5.14-rc6-rt9 release.

For !RT kernels there is no functional change.

The series is also available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git rtmutex

Changes vs. V4

- A few lockdep wait_type fixes in static and runtime initializers. Sebastian noticed while working on getting the lockdep selftests reenabled on RT.

- Missing might_sleep() invocations in RT spin/rwlocks (Sebastian)

- Add explicit owner init for local locks when lockdep is enabled instead of relying on zero initialized memory.

- Add the RT variants for local locks, which is the last lock type getting special treatment on RT.

The lockdep selftest changes are not yet ready and will be posted in a separate submission.

Thanks,

tglx

---
 b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c |    4 
 b/include/linux/debug_locks.h                       |    3 
 b/include/linux/local_lock_internal.h               |   90 +
 b/include/linux/mutex.h                             |   92 +
 b/include/linux/preempt.h                           |    4 
 b/include/linux/rbtree.h                            |   30 
 b/include/linux/rbtree_types.h                      |   34 
 b/include/linux/rtmutex.h                           |   63 -
 b/include/linux/rwbase_rt.h                         |   38 
 b/include/linux/rwlock_rt.h                         |  140 ++
 b/include/linux/rwlock_types.h                      |   53 
 b/include/linux/rwsem.h                             |   78 +
 b/include/linux/sched.h                             |  119 +-
 b/include/linux/sched/wake_q.h                      |    8 
 b/include/linux/spinlock.h                          |   15 
 b/include/linux/spinlock_api_smp.h                  |    3 
 b/include/linux/spinlock_rt.h                       |  159 ++
 b/include/linux/spinlock_types.h                    |   89 -
 b/include/linux/spinlock_types_raw.h                |   73 +
 b/include/linux/ww_mutex.h                          |   50 
 b/kernel/Kconfig.locks                              |    2 
 b/kernel/futex.c                                    |  556 ++++++---
 b/kernel/locking/Makefile                           |    3 
 b/kernel/locking/mutex-debug.c                      |    5 
 b/kernel/locking/mutex.c                            |  431 -------
 b/kernel/locking/mutex.h                            |   48 
 b/kernel/locking/rtmutex.c                          | 1134 +++++++++-----------
 b/kernel/locking/rtmutex_api.c                      |  590 ++++++++++
 b/kernel/locking/rtmutex_common.h                   |  122 +-
 b/kernel/locking/rwbase_rt.c                        |  263 ++++
 b/kernel/locking/rwsem.c                            |  109 +
 b/kernel/locking/spinlock.c                         |    7 
 b/kernel/locking/spinlock_debug.c                   |    5 
 b/kernel/locking/spinlock_rt.c                      |  263 ++++
 b/kernel/locking/ww_mutex.h                         |  569 ++++++++++
 b/kernel/locking/ww_rt_mutex.c                      |   76 +
 b/kernel/rcu/tree_plugin.h                          |    6 
 b/kernel/sched/core.c                               |  109 +
 b/lib/Kconfig.debug                                 |   11 
 b/lib/test_lockup.c                                 |    8 
 kernel/locking/mutex-debug.h                        |   29 
 41 files changed, 3940 insertions(+), 1551 deletions(-)