Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 1 | #ifndef __LINUX_DEBUG_LOCKING_H |
| 2 | #define __LINUX_DEBUG_LOCKING_H |
| 3 | |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/atomic.h> |
| 6 | #include <linux/bug.h> |
| 7 | |
| 8 | struct task_struct; |
| 9 | |
| 10 | extern int debug_locks; |
| 11 | extern int debug_locks_silent; |
| 12 | |
| 13 | |
| 14 | static inline int __debug_locks_off(void) |
| 15 | { |
| 16 | return xchg(&debug_locks, 0); |
| 17 | } |
| 18 | |
| 19 | extern int debug_locks_off(void); |
| 20 | |
| 21 | #define DEBUG_LOCKS_WARN_ON(c) \ |
| 22 | ({ \ |
| 23 | int __ret = 0; \ |
| 24 | \ |
| 25 | if (!oops_in_progress && unlikely(c)) { \ |
| 26 | if (debug_locks_off() && !debug_locks_silent) \ |
| 27 | WARN_ON(1); \ |
| 28 | __ret = 1; \ |
| 29 | } \ |
| 30 | __ret; \ |
| 31 | }) |
| 32 | |
| 33 | #ifdef CONFIG_SMP |
| 34 | # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c) |
| 35 | #else |
| 36 | # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0) |
| 37 | #endif |
| 38 | |
| 39 | #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS |
| 40 | extern void locking_selftest(void); |
| 41 | #else |
| 42 | # define locking_selftest() do { } while (0) |
| 43 | #endif |
| 44 | |
| 45 | struct task_struct; |
| 46 | |
| 47 | #ifdef CONFIG_LOCKDEP |
| 48 | extern void debug_show_all_locks(void); |
| 49 | extern void debug_show_held_locks(struct task_struct *task); |
| 50 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
| 51 | extern void debug_check_no_locks_held(struct task_struct *task); |
| 52 | #else |
| 53 | static inline void debug_show_all_locks(void) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | static inline void debug_show_held_locks(struct task_struct *task) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | static inline void |
| 62 | debug_check_no_locks_freed(const void *from, unsigned long len) |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | static inline void |
| 67 | debug_check_no_locks_held(struct task_struct *task) |
| 68 | { |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | #endif |