19a11b49aSIngo Molnar #ifndef __LINUX_DEBUG_LOCKING_H 29a11b49aSIngo Molnar #define __LINUX_DEBUG_LOCKING_H 39a11b49aSIngo Molnar 4ca31e146SEduard - Gabriel Munteanu #include <linux/kernel.h> 5*60063497SArun Sharma #include <linux/atomic.h> 627b19565SIngo Molnar #include <asm/system.h> 7ca31e146SEduard - Gabriel Munteanu 89b7f750dSAlexey Dobriyan struct task_struct; 99b7f750dSAlexey Dobriyan 109a11b49aSIngo Molnar extern int debug_locks; 119a11b49aSIngo Molnar extern int debug_locks_silent; 129a11b49aSIngo Molnar 139eeba613SFrederic Weisbecker 149eeba613SFrederic Weisbecker static inline int __debug_locks_off(void) 159eeba613SFrederic Weisbecker { 169eeba613SFrederic Weisbecker return xchg(&debug_locks, 0); 179eeba613SFrederic Weisbecker } 189eeba613SFrederic Weisbecker 199a11b49aSIngo Molnar /* 209a11b49aSIngo Molnar * Generic 'turn off all lock debugging' function: 219a11b49aSIngo Molnar */ 229a11b49aSIngo Molnar extern int debug_locks_off(void); 239a11b49aSIngo Molnar 249a11b49aSIngo Molnar #define DEBUG_LOCKS_WARN_ON(c) \ 259a11b49aSIngo Molnar ({ \ 269a11b49aSIngo Molnar int __ret = 0; \ 279a11b49aSIngo Molnar \ 2853b9d87fSAndrew Morton if (!oops_in_progress && unlikely(c)) { \ 299127d4b1SIngo Molnar if (debug_locks_off() && !debug_locks_silent) \ 309a11b49aSIngo Molnar WARN_ON(1); \ 319a11b49aSIngo Molnar __ret = 1; \ 329a11b49aSIngo Molnar } \ 339a11b49aSIngo Molnar __ret; \ 349a11b49aSIngo Molnar }) 359a11b49aSIngo Molnar 369a11b49aSIngo Molnar #ifdef CONFIG_SMP 379a11b49aSIngo Molnar # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c) 389a11b49aSIngo Molnar #else 399a11b49aSIngo Molnar # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0) 409a11b49aSIngo Molnar #endif 419a11b49aSIngo Molnar 429a11b49aSIngo Molnar #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS 439a11b49aSIngo Molnar extern void locking_selftest(void); 449a11b49aSIngo Molnar #else 459a11b49aSIngo Molnar # define locking_selftest() do { } while (0) 469a11b49aSIngo Molnar #endif 479a11b49aSIngo Molnar 48f86e4513SKyle McMartin struct task_struct; 49f86e4513SKyle McMartin 509a11b49aSIngo Molnar #ifdef CONFIG_LOCKDEP 519a11b49aSIngo Molnar extern void debug_show_all_locks(void); 529a11b49aSIngo Molnar extern void debug_show_held_locks(struct task_struct *task); 539a11b49aSIngo Molnar extern void debug_check_no_locks_freed(const void *from, unsigned long len); 549a11b49aSIngo Molnar extern void debug_check_no_locks_held(struct task_struct *task); 559a11b49aSIngo Molnar #else 569a11b49aSIngo Molnar static inline void debug_show_all_locks(void) 579a11b49aSIngo Molnar { 589a11b49aSIngo Molnar } 599a11b49aSIngo Molnar 609a11b49aSIngo Molnar static inline void debug_show_held_locks(struct task_struct *task) 619a11b49aSIngo Molnar { 629a11b49aSIngo Molnar } 639a11b49aSIngo Molnar 649a11b49aSIngo Molnar static inline void 659a11b49aSIngo Molnar debug_check_no_locks_freed(const void *from, unsigned long len) 669a11b49aSIngo Molnar { 679a11b49aSIngo Molnar } 689a11b49aSIngo Molnar 699a11b49aSIngo Molnar static inline void 709a11b49aSIngo Molnar debug_check_no_locks_held(struct task_struct *task) 719a11b49aSIngo Molnar { 729a11b49aSIngo Molnar } 739a11b49aSIngo Molnar #endif 749a11b49aSIngo Molnar 759a11b49aSIngo Molnar #endif 76