2021-07-30 14:22:48

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 00/63] locking, sched: The PREEMPT-RT locking infrastructure

Folks,

the following series is an update to V1 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, rw_semaphore, spinlock, rwlock

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

ww_mutexes are also not substituted because the usage sites are not really
RT relevant and it would require a full reimplementation to make them work
correctly based on rtmutex. That might change in the future, but for now
utilizing the existing variant is considered a safe and sane choice.

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 isolation of the ww_mutex code which allows to build it stand alone.
The typedef based solution might look a bit odd on the first glance,
but that turned out to be the least intrusive variant.

- 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 quite some internal testing in RT kernels and is part
of the recent 5.14-rc3-rt2 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

and fully integrated into the v5.14-rc3-rt2 release:

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

Changes vs. V1:

- Simplify the scheduler state logic (Peter Zijlstra)

- Split out rt_mutex_base to avoid that wrapped locks carry an unused
lockdep map, which in turn avoids extra interfaces. (Peter Zijlstra)

- Pick up Peter's initial version of an rtmutex based ww_mutex and make
it work. This replaces the mutex.c split of V1

- Pick up the BUG -> lockdep_assert_held() patch from Peter

- Extend adaptive spinwait to all rtmutex based locks which makes
hackbench less unhappy.

- Various review comments addressed

Thanks,

tglx
---
a/kernel/locking/mutex-debug.h | 29
b/include/linux/rbtree_types.h | 34
b/include/linux/rwbase_rt.h | 38
b/include/linux/rwlock_rt.h | 140 ++
b/include/linux/spinlock_rt.h | 151 +++
b/include/linux/spinlock_types_raw.h | 65 +
b/kernel/locking/rtmutex_api.c | 590 +++++++++++
b/kernel/locking/rwbase_rt.c | 263 +++++
b/kernel/locking/spinlock_rt.c | 257 +++++
b/kernel/locking/ww_mutex.h | 569 +++++++++++
b/kernel/locking/ww_rt_mutex.c | 76 +
drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 4
include/linux/debug_locks.h | 3
include/linux/mutex.h | 93 +
include/linux/preempt.h | 4
include/linux/rbtree.h | 30
include/linux/rtmutex.h | 55 -
include/linux/rwlock_types.h | 39
include/linux/rwsem.h | 58 +
include/linux/sched.h | 77 +
include/linux/sched/wake_q.h | 14
include/linux/spinlock.h | 15
include/linux/spinlock_api_smp.h | 3
include/linux/spinlock_types.h | 45
include/linux/ww_mutex.h | 50 -
kernel/Kconfig.locks | 2
kernel/futex.c | 479 +++++++--
kernel/locking/Makefile | 3
kernel/locking/mutex-debug.c | 5
kernel/locking/mutex.c | 431 --------
kernel/locking/mutex.h | 33
kernel/locking/rtmutex.c | 1082 +++++++++-------------
kernel/locking/rtmutex_common.h | 122 +-
kernel/locking/rwsem.c | 109 ++
kernel/locking/spinlock.c | 7
kernel/locking/spinlock_debug.c | 5
kernel/rcu/tree_plugin.h | 6
kernel/sched/core.c | 113 +-
lib/Kconfig.debug | 11
lib/test_lockup.c | 8
40 files changed, 3733 insertions(+), 1385 deletions(-)



Subject: Re: [patch 00/63] locking, sched: The PREEMPT-RT locking infrastructure

On 7/30/21 3:50 PM, Thomas Gleixner wrote:
> Folks,
>
> the following series is an update to V1 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, rw_semaphore, spinlock, rwlock
>
> semaphores are not substituted because they do not provide strict owner
> semantics.
>
> ww_mutexes are also not substituted because the usage sites are not really
> RT relevant and it would require a full reimplementation to make them work
> correctly based on rtmutex. That might change in the future, but for now
> utilizing the existing variant is considered a safe and sane choice.
>
> 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 isolation of the ww_mutex code which allows to build it stand alone.
> The typedef based solution might look a bit odd on the first glance,
> but that turned out to be the least intrusive variant.
>
> - 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 quite some internal testing in RT kernels and is part
> of the recent 5.14-rc3-rt2 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
>
> and fully integrated into the v5.14-rc3-rt2 release:
>
> https://lore.kernel.org/r/[email protected]

Thomas,

While reviewing/testing this series, I ended up finding some (simple) typos,
reporting them here:

patch 2:
unneccesary -> unnecessary

patches 2/3/27/29/31:
accross -> across

patch 4:
optimze -> optimize

patches 4/15:
seperately -> separately

patches 5(2x)/12/17/18:
seperate -> separate

patch 11:
appropiate -> appropriate

patch 15:
indentical -> identical

patch 34:
Preperatory -> Preparatory

patch 53:
completness -> completeness

patch 61:
Signficant -> Significant

continuing the testing...

-- Daniel