mm, slub: make slab_lock() disable irqs with PREEMPT_RT
authorVlastimil Babka <vbabka@suse.cz>
Fri, 4 Jun 2021 10:55:55 +0000 (12:55 +0200)
committerVlastimil Babka <vbabka@suse.cz>
Sat, 4 Sep 2021 08:17:33 +0000 (10:17 +0200)
commita2b4ae8bfd9c10e3c1c1966bd3c8d8b7c9026aaf
treeb30dacf73f1b9db0d934d7dcbc3f7bbaac6bf0cb
parent94ef0304e2b8dc942f46c74a13841d6b61f61d2f
mm, slub: make slab_lock() disable irqs with PREEMPT_RT

We need to disable irqs around slab_lock() (a bit spinlock) to make it
irq-safe. Most calls to slab_lock() are nested under spin_lock_irqsave() which
doesn't disable irqs on PREEMPT_RT, so add explicit disabling with PREEMPT_RT.
The exception is cmpxchg_double_slab() which already disables irqs, so use a
__slab_[un]lock() variant without irq disable there.

slab_[un]lock() thus needs a flags pointer parameter, which is unused on !RT.
free_debug_processing() now has two flags variables, which looks odd, but only
one is actually used - the one used in spin_lock_irqsave() on !RT and the one
used in slab_lock() on RT.

As a result, __cmpxchg_double_slab() and cmpxchg_double_slab() become
effectively identical on RT, as both will disable irqs, which is necessary on
RT as most callers of this function also rely on irqsaving lock operations.
Thus, assert that irqs are already disabled in __cmpxchg_double_slab() only on
!RT and also change the VM_BUG_ON assertion to the more standard lockdep_assert
one.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c