debug_locks.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __LINUX_DEBUG_LOCKING_H
  2. #define __LINUX_DEBUG_LOCKING_H
  3. extern int debug_locks;
  4. extern int debug_locks_silent;
  5. /*
  6. * Generic 'turn off all lock debugging' function:
  7. */
  8. extern int debug_locks_off(void);
  9. /*
  10. * In the debug case we carry the caller's instruction pointer into
  11. * other functions, but we dont want the function argument overhead
  12. * in the nondebug case - hence these macros:
  13. */
  14. #define _RET_IP_ (unsigned long)__builtin_return_address(0)
  15. #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
  16. #define DEBUG_LOCKS_WARN_ON(c) \
  17. ({ \
  18. int __ret = 0; \
  19. \
  20. if (unlikely(c)) { \
  21. if (debug_locks_off()) \
  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. #ifdef CONFIG_LOCKDEP
  38. extern void debug_show_all_locks(void);
  39. extern void debug_show_held_locks(struct task_struct *task);
  40. extern void debug_check_no_locks_freed(const void *from, unsigned long len);
  41. extern void debug_check_no_locks_held(struct task_struct *task);
  42. #else
  43. static inline void debug_show_all_locks(void)
  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