History

locking/lockdep: Add IRQs disabled/enabled assertion APIs: lockdep_assert_irqs_enabled()/disabled()

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.

Frederic Weisbecker committed 9 years ago

Commit f54bb2e1 parent 11752ad1 file · +15 −0Browse files

Unified · Split

include/linux/lockdep.h+15−0
@@ -725,9 +725,24 @@ do { \ · 724 unmodified lines
725 lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_); \725 lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_); \
726 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \726 lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
727} while (0)727} while (0)
728
729#define lockdep_assert_irqs_enabled() do { \
730 WARN_ONCE(debug_locks && !current->lockdep_recursion && \
731 !current->hardirqs_enabled, \
732 "IRQs not enabled as expected\n"); \
733 } while (0)
734
735#define lockdep_assert_irqs_disabled() do { \
736 WARN_ONCE(debug_locks && !current->lockdep_recursion && \
737 current->hardirqs_enabled, \
738 "IRQs not disabled as expected\n"); \
739 } while (0)
740
728#else741#else
729# define might_lock(lock) do { } while (0)742# define might_lock(lock) do { } while (0)
730# define might_lock_read(lock) do { } while (0)743# define might_lock_read(lock) do { } while (0)
744# define lockdep_assert_irqs_enabled() do { } while (0)
745# define lockdep_assert_irqs_disabled() do { } while (0)
731#endif746#endif
732 747
733#ifdef CONFIG_LOCKDEP748#ifdef CONFIG_LOCKDEP