blob: 94f20c1488a19cff3b21e9da5e58d3114c23ffcf [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>
Arun Sharma60063492011-07-26 16:09:06 -07005#include <linux/atomic.h>
Paul Gortmaker187f1882011-11-23 20:12:59 -05006#include <linux/bug.h>
Ingo Molnar27b19562009-04-14 11:03:12 +02007#include <asm/system.h>
Eduard - Gabriel Munteanuca31e142008-07-05 12:14:23 +03008
Alexey Dobriyan9b7f7502006-08-05 12:14:27 -07009struct task_struct;
10
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070011extern int debug_locks;
12extern int debug_locks_silent;
13
Frederic Weisbecker9eeba612009-04-11 03:17:17 +020014
15static inline int __debug_locks_off(void)
16{
17 return xchg(&debug_locks, 0);
18}
19
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070020/*
21 * Generic 'turn off all lock debugging' function:
22 */
23extern int debug_locks_off(void);
24
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070025#define DEBUG_LOCKS_WARN_ON(c) \
26({ \
27 int __ret = 0; \
28 \
Andrew Morton53b9d872008-09-11 17:02:58 -070029 if (!oops_in_progress && unlikely(c)) { \
Ingo Molnar9127d4b2006-12-22 01:08:52 -080030 if (debug_locks_off() && !debug_locks_silent) \
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070031 WARN_ON(1); \
32 __ret = 1; \
33 } \
34 __ret; \
35})
36
37#ifdef CONFIG_SMP
38# define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
39#else
40# define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
41#endif
42
43#ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
44 extern void locking_selftest(void);
45#else
46# define locking_selftest() do { } while (0)
47#endif
48
Kyle McMartinf86e4512006-08-13 21:09:31 -040049struct task_struct;
50
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070051#ifdef CONFIG_LOCKDEP
52extern void debug_show_all_locks(void);
53extern void debug_show_held_locks(struct task_struct *task);
54extern void debug_check_no_locks_freed(const void *from, unsigned long len);
55extern void debug_check_no_locks_held(struct task_struct *task);
56#else
57static inline void debug_show_all_locks(void)
58{
59}
60
Ingo Molnar9a11b49a2006-07-03 00:24:33 -070061static inline void debug_show_held_locks(struct task_struct *task)
62{
63}
64
65static inline void
66debug_check_no_locks_freed(const void *from, unsigned long len)
67{
68}
69
70static inline void
71debug_check_no_locks_held(struct task_struct *task)
72{
73}
74#endif
75
76#endif