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 | |
Alexey Dobriyan | 9b7f750 | 2006-08-05 12:14:27 -0700 | [diff] [blame] | 4 | struct task_struct; |
| 5 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 6 | extern int debug_locks; |
| 7 | extern int debug_locks_silent; |
| 8 | |
| 9 | /* |
| 10 | * Generic 'turn off all lock debugging' function: |
| 11 | */ |
| 12 | extern int debug_locks_off(void); |
| 13 | |
| 14 | /* |
| 15 | * In the debug case we carry the caller's instruction pointer into |
| 16 | * other functions, but we dont want the function argument overhead |
| 17 | * in the nondebug case - hence these macros: |
| 18 | */ |
| 19 | #define _RET_IP_ (unsigned long)__builtin_return_address(0) |
| 20 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) |
| 21 | |
| 22 | #define DEBUG_LOCKS_WARN_ON(c) \ |
| 23 | ({ \ |
| 24 | int __ret = 0; \ |
| 25 | \ |
| 26 | if (unlikely(c)) { \ |
Ingo Molnar | 9127d4b | 2006-12-22 01:08:52 -0800 | [diff] [blame] | 27 | if (debug_locks_off() && !debug_locks_silent) \ |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 28 | WARN_ON(1); \ |
| 29 | __ret = 1; \ |
| 30 | } \ |
| 31 | __ret; \ |
| 32 | }) |
| 33 | |
| 34 | #ifdef CONFIG_SMP |
| 35 | # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c) |
| 36 | #else |
| 37 | # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0) |
| 38 | #endif |
| 39 | |
| 40 | #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS |
| 41 | extern void locking_selftest(void); |
| 42 | #else |
| 43 | # define locking_selftest() do { } while (0) |
| 44 | #endif |
| 45 | |
Kyle McMartin | f86e451 | 2006-08-13 21:09:31 -0400 | [diff] [blame] | 46 | struct task_struct; |
| 47 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 48 | #ifdef CONFIG_LOCKDEP |
| 49 | extern void debug_show_all_locks(void); |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 50 | extern void __debug_show_held_locks(struct task_struct *task); |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 51 | extern void debug_show_held_locks(struct task_struct *task); |
| 52 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
| 53 | extern void debug_check_no_locks_held(struct task_struct *task); |
| 54 | #else |
| 55 | static inline void debug_show_all_locks(void) |
| 56 | { |
| 57 | } |
| 58 | |
Ingo Molnar | 82a1fcb | 2008-01-25 21:08:02 +0100 | [diff] [blame] | 59 | static inline void __debug_show_held_locks(struct task_struct *task) |
| 60 | { |
| 61 | } |
| 62 | |
Ingo Molnar | 9a11b49a | 2006-07-03 00:24:33 -0700 | [diff] [blame] | 63 | static inline void debug_show_held_locks(struct task_struct *task) |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | static inline void |
| 68 | debug_check_no_locks_freed(const void *from, unsigned long len) |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | static inline void |
| 73 | debug_check_no_locks_held(struct task_struct *task) |
| 74 | { |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | #endif |