debug_locks.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_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
  52. debug_check_no_locks_freed(const void *from, unsigned long len)
  53. {
  54. }
  55. static inline void
  56. debug_check_no_locks_held(struct task_struct *task)
  57. {
  58. }
  59. #endif
  60. #endif