debug_locks.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef __LINUX_DEBUG_LOCKING_H
  2. #define __LINUX_DEBUG_LOCKING_H
  3. #include <linux/kernel.h>
  4. #include <linux/atomic.h>
  5. #include <linux/bug.h>
  6. struct task_struct;
  7. extern int debug_locks;
  8. extern int debug_locks_silent;
  9. static inline int __debug_locks_off(void)
  10. {
  11. return xchg(&debug_locks, 0);
  12. }
  13. /*
  14. * Generic 'turn off all lock debugging' function:
  15. */
  16. extern int debug_locks_off(void);
  17. #define DEBUG_LOCKS_WARN_ON(c) \
  18. ({ \
  19. int __ret = 0; \
  20. \
  21. if (!oops_in_progress && unlikely(c)) { \
  22. if (debug_locks_off() && !debug_locks_silent) \
  23. WARN(1, "DEBUG_LOCKS_WARN_ON(%s)", #c); \
  24. __ret = 1; \
  25. } \
  26. __ret; \
  27. })
  28. #ifdef CONFIG_SMP
  29. # define SMP_DEBUG_LOCKS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
  30. #else
  31. # define SMP_DEBUG_LOCKS_WARN_ON(c) do { } while (0)
  32. #endif
  33. #ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS
  34. extern void locking_selftest(void);
  35. #else
  36. # define locking_selftest() do { } while (0)
  37. #endif
  38. struct task_struct;
  39. #ifdef CONFIG_LOCKDEP
  40. extern void debug_show_all_locks(void);
  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(void);
  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
  52. debug_check_no_locks_freed(const void *from, unsigned long len)
  53. {
  54. }
  55. static inline void
  56. debug_check_no_locks_held(void)
  57. {
  58. }
  59. #endif
  60. #endif