xref: /linux/include/linux/debug_locks.h (revision ca31e146d5c2fe51498e619eb3a64782d02e310a)
19a11b49aSIngo Molnar #ifndef __LINUX_DEBUG_LOCKING_H
29a11b49aSIngo Molnar #define __LINUX_DEBUG_LOCKING_H
39a11b49aSIngo Molnar 
4*ca31e146SEduard - Gabriel Munteanu #include <linux/kernel.h>
5*ca31e146SEduard - Gabriel Munteanu 
69b7f750dSAlexey Dobriyan struct task_struct;
79b7f750dSAlexey Dobriyan 
89a11b49aSIngo Molnar extern int debug_locks;
99a11b49aSIngo Molnar extern int debug_locks_silent;
109a11b49aSIngo Molnar 
119a11b49aSIngo Molnar /*
129a11b49aSIngo Molnar  * Generic 'turn off all lock debugging' function:
139a11b49aSIngo Molnar  */
149a11b49aSIngo Molnar extern int debug_locks_off(void);
159a11b49aSIngo Molnar 
169a11b49aSIngo Molnar #define DEBUG_LOCKS_WARN_ON(c)						\
179a11b49aSIngo Molnar ({									\
189a11b49aSIngo Molnar 	int __ret = 0;							\
199a11b49aSIngo Molnar 									\
209a11b49aSIngo Molnar 	if (unlikely(c)) {						\
219127d4b1SIngo Molnar 		if (debug_locks_off() && !debug_locks_silent)		\
229a11b49aSIngo Molnar 			WARN_ON(1);					\
239a11b49aSIngo Molnar 		__ret = 1;						\
249a11b49aSIngo Molnar 	}								\
259a11b49aSIngo Molnar 	__ret;								\
269a11b49aSIngo Molnar })
279a11b49aSIngo Molnar 
289a11b49aSIngo Molnar #ifdef CONFIG_SMP
299a11b49aSIngo Molnar # define SMP_DEBUG_LOCKS_WARN_ON(c)			DEBUG_LOCKS_WARN_ON(c)
309a11b49aSIngo Molnar #else
319a11b49aSIngo Molnar # define SMP_DEBUG_LOCKS_WARN_ON(c)			do { } while (0)
329a11b49aSIngo Molnar #endif
339a11b49aSIngo Molnar 
349a11b49aSIngo Molnar #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
359a11b49aSIngo Molnar   extern void locking_selftest(void);
369a11b49aSIngo Molnar #else
379a11b49aSIngo Molnar # define locking_selftest()	do { } while (0)
389a11b49aSIngo Molnar #endif
399a11b49aSIngo Molnar 
40f86e4513SKyle McMartin struct task_struct;
41f86e4513SKyle McMartin 
429a11b49aSIngo Molnar #ifdef CONFIG_LOCKDEP
439a11b49aSIngo Molnar extern void debug_show_all_locks(void);
4482a1fcb9SIngo Molnar extern void __debug_show_held_locks(struct task_struct *task);
459a11b49aSIngo Molnar extern void debug_show_held_locks(struct task_struct *task);
469a11b49aSIngo Molnar extern void debug_check_no_locks_freed(const void *from, unsigned long len);
479a11b49aSIngo Molnar extern void debug_check_no_locks_held(struct task_struct *task);
489a11b49aSIngo Molnar #else
499a11b49aSIngo Molnar static inline void debug_show_all_locks(void)
509a11b49aSIngo Molnar {
519a11b49aSIngo Molnar }
529a11b49aSIngo Molnar 
5382a1fcb9SIngo Molnar static inline void __debug_show_held_locks(struct task_struct *task)
5482a1fcb9SIngo Molnar {
5582a1fcb9SIngo Molnar }
5682a1fcb9SIngo Molnar 
579a11b49aSIngo Molnar static inline void debug_show_held_locks(struct task_struct *task)
589a11b49aSIngo Molnar {
599a11b49aSIngo Molnar }
609a11b49aSIngo Molnar 
619a11b49aSIngo Molnar static inline void
629a11b49aSIngo Molnar debug_check_no_locks_freed(const void *from, unsigned long len)
639a11b49aSIngo Molnar {
649a11b49aSIngo Molnar }
659a11b49aSIngo Molnar 
669a11b49aSIngo Molnar static inline void
679a11b49aSIngo Molnar debug_check_no_locks_held(struct task_struct *task)
689a11b49aSIngo Molnar {
699a11b49aSIngo Molnar }
709a11b49aSIngo Molnar #endif
719a11b49aSIngo Molnar 
729a11b49aSIngo Molnar #endif
73