Skip to content

Commit a738e9b

Browse files
committed
mm/debug: Provide VM_WARN_ON_IRQS_ENABLED()
Some places in the VM code expect interrupts disabled, which is a valid expectation on non-PREEMPT_RT kernels, but does not hold on RT kernels in some places because the RT spinlock substitution does not disable interrupts. To avoid sprinkling CONFIG_PREEMPT_RT conditionals into those places, provide VM_WARN_ON_IRQS_ENABLED() which is only enabled when VM_DEBUG=y and PREEMPT_RT=n. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Michal Hocko <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7a025e9 commit a738e9b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/linux/mmdebug.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ void dump_mm(const struct mm_struct *mm);
9494
#define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond)
9595
#endif
9696

97+
#ifdef CONFIG_DEBUG_VM_IRQSOFF
98+
#define VM_WARN_ON_IRQS_ENABLED() WARN_ON_ONCE(!irqs_disabled())
99+
#else
100+
#define VM_WARN_ON_IRQS_ENABLED() do { } while (0)
101+
#endif
102+
97103
#ifdef CONFIG_DEBUG_VIRTUAL
98104
#define VIRTUAL_BUG_ON(cond) BUG_ON(cond)
99105
#else

lib/Kconfig.debug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ config ARCH_HAS_DEBUG_VM_PGTABLE
803803
An architecture should select this when it can successfully
804804
build and run DEBUG_VM_PGTABLE.
805805

806+
config DEBUG_VM_IRQSOFF
807+
def_bool DEBUG_VM && !PREEMPT_RT
808+
806809
config DEBUG_VM
807810
bool "Debug VM"
808811
depends on DEBUG_KERNEL

0 commit comments

Comments
 (0)