Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_DEBUG_LOCKING_H |
| 2 | #define __LINUX_DEBUG_LOCKING_H |
| 3 | |
Eduard - Gabriel Munteanu | ca31e14 | 2008-07-05 12:14:23 +0300 | [diff] [blame] | 4 | #include <linux/kernel.h> |
| 5 | |
Alexey Dobriyan | 9b7f750 | 2006-08-05 12:14:27 -0700 | [diff] [blame] | 6 | struct task_struct; |
| 7 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 8 | extern int debug_locks; |
| 9 | extern int debug_locks_silent; |
| 10 | |
| 11 | /* |
| 12 | * Generic 'turn off all lock debugging' function: |
| 13 | */ |
| 14 | extern int debug_locks_off(void); |
| 15 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 16 | #define DEBUG_LOCKS_WARN_ON(c) \ |
| 17 | ({ \ |
| 18 | int __ret = 0; \ |
| 19 | \ |
Andrew Morton | 53b9d87 | 2008-09-11 17:02:58 -0700 | [diff] [blame] | 20 | if (!oops_in_progress && unlikely(c)) { \ |
Ingo Molnar | 9127d4b | 2006-12-22 01:08:52 -0800 | [diff] [blame] | 21 | if (debug_locks_off() && !debug_locks_silent) \ |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 22 | WARN_ON(1); \ |
| 23 | __ret = 1; \ |
| 24 | } \ |
| 25 | __ret; \ |
| 26 | }) |
| 27 | |
| 28 | #ifdef CONFIG_SMP |
| 29 | # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c) |
| 30 | #else |
| 31 | # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0) |
| 32 | #endif |
| 33 | |
| 34 | #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS |
| 35 | extern void locking_selftest(void); |
| 36 | #else |
| 37 | # define locking_selftest() do { } while (0) |
| 38 | #endif |
| 39 | |
Kyle McMartin | f86e451 | 2006-08-13 21:09:31 -0400 | [diff] [blame] | 40 | struct task_struct; |
| 41 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 42 | #ifdef CONFIG_LOCKDEP |
| 43 | extern void debug_show_all_locks(void); |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 44 | extern void __debug_show_held_locks(struct task_struct *task); |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 45 | extern void debug_show_held_locks(struct task_struct *task); |
| 46 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
| 47 | extern void debug_check_no_locks_held(struct task_struct *task); |
| 48 | #else |
| 49 | static inline void debug_show_all_locks(void) |
| 50 | { |
| 51 | } |
| 52 | |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 53 | static inline void __debug_show_held_locks(struct task_struct *task) |
| 54 | { |
| 55 | } |
| 56 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 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 |