debug_locks.h 1.5 KB

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