debug_locks.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __LINUX_DEBUG_LOCKING_H
  2. #define __LINUX_DEBUG_LOCKING_H
  3. #include <linux/kernel.h>
  4. #include <asm/atomic.h>
  5. struct task_struct;
  6. extern int debug_locks;
  7. extern int debug_locks_silent;
  8. static inline int __debug_locks_off(void)
  9. {
  10. return xchg(&debug_locks, 0);
  11. }
  12. /*
  13. * Generic 'turn off all lock debugging' function:
  14. */
  15. extern int debug_locks_off(void);
  16. #define DEBUG_LOCKS_WARN_ON(c) \
  17. ({ \
  18. int __ret = 0; \
  19. \
  20. if (!oops_in_progress && unlikely(c)) { \
  21. if (debug_locks_off() && !debug_locks_silent) \
  22. WARN_ON(1); \
  23. __ret = 1; \
  24. } \
  25. __ret; \
  26. })
  27. #ifdef CONFIG_SMP
  28. # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
  29. #else
  30. # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
  31. #endif
  32. #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
  33. extern void locking_selftest(void);
  34. #else
  35. # define locking_selftest() do { } while (0)
  36. #endif
  37. struct task_struct;
  38. #ifdef CONFIG_LOCKDEP
  39. extern void debug_show_all_locks(void);
  40. extern void __debug_show_held_locks(struct task_struct *task);
  41. extern void debug_show_held_locks(struct task_struct *task);
  42. extern void debug_check_no_locks_freed(const void *from, unsigned long len);
  43. extern void debug_check_no_locks_held(struct task_struct *task);
  44. #else
  45. static inline void debug_show_all_locks(void)
  46. {
  47. }
  48. static inline void __debug_show_held_locks(struct task_struct *task)
  49. {
  50. }
  51. static inline void debug_show_held_locks(struct task_struct *task)
  52. {
  53. }
  54. static inline void
  55. debug_check_no_locks_freed(const void *from, unsigned long len)
  56. {
  57. }
  58. static inline void
  59. debug_check_no_locks_held(struct task_struct *task)
  60. {
  61. }
  62. #endif
  63. #endif