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