1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_DEBUG_LOCKING_H
3 #define __LINUX_DEBUG_LOCKING_H
5 #include <linux/atomic.h>
6 #include <linux/cache.h>
10 extern int debug_locks __read_mostly;
11 extern int debug_locks_silent __read_mostly;
14 static __always_inline int __debug_locks_off(void)
16 return xchg(&debug_locks, 0);
20 * Generic 'turn off all lock debugging' function:
22 extern int debug_locks_off(void);
24 #define DEBUG_LOCKS_WARN_ON(c) \
28 if (!oops_in_progress && unlikely(c)) { \
29 instrumentation_begin(); \
30 if (debug_locks_off() && !debug_locks_silent) \
31 WARN(1, "DEBUG_LOCKS_WARN_ON(%s)", #c); \
32 instrumentation_end(); \
39 # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
41 # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
44 #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
45 extern void locking_selftest(void);
47 # define locking_selftest() do { } while (0)
53 extern void debug_show_all_locks(void);
54 extern void debug_show_held_locks(struct task_struct *task);
55 extern void debug_check_no_locks_freed(const void *from, unsigned long len);
56 extern void debug_check_no_locks_held(void);
58 static inline void debug_show_all_locks(void)
62 static inline void debug_show_held_locks(struct task_struct *task)
67 debug_check_no_locks_freed(const void *from, unsigned long len)
72 debug_check_no_locks_held(void)