blob: d084db5c3c9e4e7d2de33745c46d41488b8afacf [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001#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
8struct task_struct;
9
10extern int debug_locks;
11extern int debug_locks_silent;
12
13
14static inline int __debug_locks_off(void)
15{
16 return xchg(&debug_locks, 0);
17}
18
19extern 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
45struct task_struct;
46
47#ifdef CONFIG_LOCKDEP
48extern void debug_show_all_locks(void);
49extern void debug_show_held_locks(struct task_struct *task);
50extern void debug_check_no_locks_freed(const void *from, unsigned long len);
51extern void debug_check_no_locks_held(struct task_struct *task);
52#else
53static inline void debug_show_all_locks(void)
54{
55}
56
57static inline void debug_show_held_locks(struct task_struct *task)
58{
59}
60
61static inline void
62debug_check_no_locks_freed(const void *from, unsigned long len)
63{
64}
65
66static inline void
67debug_check_no_locks_held(struct task_struct *task)
68{
69}
70#endif
71
72#endif