debug_locks.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __LINUX_DEBUG_LOCKING_H
  2. #define __LINUX_DEBUG_LOCKING_H
  3. struct task_struct;
  4. extern int debug_locks;
  5. extern int debug_locks_silent;
  6. /*
  7. * Generic 'turn off all lock debugging' function:
  8. */
  9. extern int debug_locks_off(void);
  10. /*
  11. * In the debug case we carry the caller's instruction pointer into
  12. * other functions, but we dont want the function argument overhead
  13. * in the nondebug case - hence these macros:
  14. */
  15. #define _RET_IP_ (unsigned long)__builtin_return_address(0)
  16. #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
  17. #define DEBUG_LOCKS_WARN_ON(c) \
  18. ({ \
  19. int __ret = 0; \
  20. \
  21. if (unlikely(c)) { \
  22. if (debug_locks_off() && !debug_locks_silent) \
  23. WARN_ON(1); \
  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_show_held_locks(struct task_struct *task);
  43. extern void debug_check_no_locks_freed(const void *from, unsigned long len);
  44. extern void debug_check_no_locks_held(struct task_struct *task);
  45. #else
  46. static inline void debug_show_all_locks(void)
  47. {
  48. }
  49. static inline void __debug_show_held_locks(struct task_struct *task)
  50. {
  51. }
  52. static inline void debug_show_held_locks(struct task_struct *task)
  53. {
  54. }
  55. static inline void
  56. debug_check_no_locks_freed(const void *from, unsigned long len)
  57. {
  58. }
  59. static inline void
  60. debug_check_no_locks_held(struct task_struct *task)
  61. {
  62. }
  63. #endif
  64. #endif