]> Git Repo - linux.git/commitdiff
locking/lockdep: Add IRQs disabled/enabled assertion APIs: lockdep_assert_irqs_enable...
authorFrederic Weisbecker <[email protected]>
Mon, 6 Nov 2017 15:01:17 +0000 (16:01 +0100)
committerIngo Molnar <[email protected]>
Wed, 8 Nov 2017 10:13:47 +0000 (11:13 +0100)
Checking whether IRQs are enabled or disabled is a very common sanity
check, however not free of overhead especially on fastpath where such
assertion is very common.

Lockdep is a good host for such concurrency correctness check and it
even already tracks down IRQs disablement state. Just reuse its
machinery. This will allow us to get rid of the flags pop and check
overhead from fast path when kernel is built for production.

Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>
Acked-by: Thomas Gleixner <[email protected]>
Cc: David S . Miller <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Tejun Heo <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
include/linux/lockdep.h

index 02720769c159db88a5e45d762d793e627a4e4089..a842551fe0449a38df5510a39d3fdc4760caa0ee 100644 (file)
@@ -725,9 +725,24 @@ do {                                                                       \
        lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_);    \
        lock_release(&(lock)->dep_map, 0, _THIS_IP_);                   \
 } while (0)
+
+#define lockdep_assert_irqs_enabled()  do {                            \
+               WARN_ONCE(debug_locks && !current->lockdep_recursion && \
+                         !current->hardirqs_enabled,                   \
+                         "IRQs not enabled as expected\n");            \
+       } while (0)
+
+#define lockdep_assert_irqs_disabled() do {                            \
+               WARN_ONCE(debug_locks && !current->lockdep_recursion && \
+                         current->hardirqs_enabled,                    \
+                         "IRQs not disabled 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)
 #endif
 
 #ifdef CONFIG_LOCKDEP
This page took 0.054579 seconds and 4 git commands to generate.