preempt: Provide preempt_[dis|en]able_nested()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 Aug 2022 16:41:24 +0000 (18:41 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 19 Sep 2022 12:35:07 +0000 (14:35 +0200)
commit555bb4ccd1dd78d0263eae31629fe1fdd65c1fb5
tree88891b9221198fa70d63dc7be7cfa38aa1475318
parent521a547ced6477c54b4b0cc206000406c221b4d6
preempt: Provide preempt_[dis|en]able_nested()

On PREEMPT_RT enabled kernels, spinlocks and rwlocks are neither disabling
preemption nor interrupts. Though there are a few places which depend on
the implicit preemption/interrupt disable of those locks, e.g. seqcount
write sections, per CPU statistics updates etc.

To avoid sprinkling CONFIG_PREEMPT_RT conditionals all over the place, add
preempt_disable_nested() and preempt_enable_nested() which should be
descriptive enough.

Add a lockdep assertion for the !PREEMPT_RT case to catch callers which
do not have preemption disabled.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220825164131.402717-2-bigeasy@linutronix.de
include/linux/preempt.h