blob: 493dedb7a67ba17a67c47540bc1f188fc097c44e [file] [log] [blame]
Ingo Molnar9a11b49a2006-07-03 00:24:33 -07001#ifndef __LINUX_DEBUG_LOCKING_H
2#define __LINUX_DEBUG_LOCKING_H
3
Eduard - Gabriel Munteanuca31e142008-07-05 12:14:23 +03004#include <linux/kernel.h>
Frederic Weisbecker9eeba612009-04-11 03:17:17 +02005#include <asm/atomic.h>
Eduard - Gabriel Munteanuca31e142008-07-05 12:14:23 +03006
Alexey Dobriyan9b7f7502006-08-05 12:14:27 -07007struct task_struct;
8
Ingo Molnar9a11b49a2006-07-03 00:24:33 -07009extern int debug_locks;
10extern int debug_locks_silent;
11
Frederic Weisbecker9eeba612009-04-11 03:17:17 +020012
13static inline int __debug_locks_off(void)
14{
15 return xchg(&debug_locks, 0);
16}
17
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070018/*
19 * Generic 'turn off all lock debugging' function:
20 */
21extern int debug_locks_off(void);
22
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070023#define DEBUG_LOCKS_WARN_ON(c) \
24({ \
25 int __ret = 0; \
26 \
Andrew Morton53b9d872008-09-11 17:02:58 -070027 if (!oops_in_progress && unlikely(c)) { \
Ingo Molnar9127d4b2006-12-22 01:08:52 -080028 if (debug_locks_off() && !debug_locks_silent) \
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070029 WARN_ON(1); \
30 __ret = 1; \
31 } \
32 __ret; \
33})
34
35#ifdef CONFIG_SMP
36# define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
37#else
38# define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
39#endif
40
41#ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
42 extern void locking_selftest(void);
43#else
44# define locking_selftest() do { } while (0)
45#endif
46
Kyle McMartinf86e4512006-08-13 21:09:31 -040047struct task_struct;
48
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070049#ifdef CONFIG_LOCKDEP
50extern void debug_show_all_locks(void);
Ingo Molnar82a1fcb2008-01-25 21:08:02 +010051extern void __debug_show_held_locks(struct task_struct *task);
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070052extern void debug_show_held_locks(struct task_struct *task);
53extern void debug_check_no_locks_freed(const void *from, unsigned long len);
54extern void debug_check_no_locks_held(struct task_struct *task);
55#else
56static inline void debug_show_all_locks(void)
57{
58}
59
Ingo Molnar82a1fcb2008-01-25 21:08:02 +010060static inline void __debug_show_held_locks(struct task_struct *task)
61{
62}
63
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070064static inline void debug_show_held_locks(struct task_struct *task)
65{
66}
67
68static inline void
69debug_check_no_locks_freed(const void *from, unsigned long len)
70{
71}
72
73static inline void
74debug_check_no_locks_held(struct task_struct *task)
75{
76}
77#endif
78
79#endif