[RFC PATCH 1/2] lockdep: Add a assert_in_softirq()

From: Sebastian Andrzej Siewior
Date: Fri May 04 2018 - 13:52:40 EST


From: Anna-Maria Gleixner <anna-maria@xxxxxxxxxxxxx>

Instead of directly warn on wrong context, check if softirq context is
set. This check could be a nop on RT.

Signed-off-by: Anna-Maria Gleixner <anna-maria@xxxxxxxxxxxxx>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
include/linux/lockdep.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 6fc77d4dbdcd..59363c3047c6 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -608,11 +608,17 @@ do { \
"IRQs not disabled as expected\n"); \
} while (0)

+#define lockdep_assert_in_softirq() do { \
+ WARN_ONCE(debug_locks && !current->lockdep_recursion && \
+ !current->softirq_context, \
+ "Not in softirq context as expected\n"); \
+ } while (0)
#else
# define might_lock(lock) do { } while (0)
# define might_lock_read(lock) do { } while (0)
# define lockdep_assert_irqs_enabled() do { } while (0)
# define lockdep_assert_irqs_disabled() do { } while (0)
+# define lockdep_assert_in_softirq() do { } while (0)
#endif

#ifdef CONFIG_LOCKDEP
--
2.17.0