0001
0002 #ifndef __LINUX_DEBUG_LOCKING_H
0003 #define __LINUX_DEBUG_LOCKING_H
0004
0005 #include <linux/atomic.h>
0006 #include <linux/cache.h>
0007
0008 struct task_struct;
0009
0010 extern int debug_locks __read_mostly;
0011 extern int debug_locks_silent __read_mostly;
0012
0013
0014 static __always_inline int __debug_locks_off(void)
0015 {
0016 return xchg(&debug_locks, 0);
0017 }
0018
0019
0020
0021
0022 extern int debug_locks_off(void);
0023
0024 #define DEBUG_LOCKS_WARN_ON(c) \
0025 ({ \
0026 int __ret = 0; \
0027 \
0028 if (!oops_in_progress && unlikely(c)) { \
0029 instrumentation_begin(); \
0030 if (debug_locks_off() && !debug_locks_silent) \
0031 WARN(1, "DEBUG_LOCKS_WARN_ON(%s)", #c); \
0032 instrumentation_end(); \
0033 __ret = 1; \
0034 } \
0035 __ret; \
0036 })
0037
0038 #ifdef CONFIG_SMP
0039 # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
0040 #else
0041 # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
0042 #endif
0043
0044 #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
0045 extern void locking_selftest(void);
0046 #else
0047 # define locking_selftest() do { } while (0)
0048 #endif
0049
0050 #ifdef CONFIG_LOCKDEP
0051 extern void debug_show_all_locks(void);
0052 extern void debug_show_held_locks(struct task_struct *task);
0053 extern void debug_check_no_locks_freed(const void *from, unsigned long len);
0054 extern void debug_check_no_locks_held(void);
0055 #else
0056 static inline void debug_show_all_locks(void)
0057 {
0058 }
0059
0060 static inline void debug_show_held_locks(struct task_struct *task)
0061 {
0062 }
0063
0064 static inline void
0065 debug_check_no_locks_freed(const void *from, unsigned long len)
0066 {
0067 }
0068
0069 static inline void
0070 debug_check_no_locks_held(void)
0071 {
0072 }
0073 #endif
0074
0075 #endif