irqflags.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * include/linux/irqflags.h
  3. *
  4. * IRQ flags tracing: follow the state of the hardirq and softirq flags and
  5. * provide callbacks for transitions between ON and OFF states.
  6. *
  7. * This file gets included from lowlevel asm headers too, to provide
  8. * wrapped versions of the local_irq_*() APIs, based on the
  9. * raw_local_irq_*() macros from the lowlevel headers.
  10. */
  11. #ifndef _LINUX_TRACE_IRQFLAGS_H
  12. #define _LINUX_TRACE_IRQFLAGS_H
  13. #ifdef CONFIG_TRACE_IRQFLAGS
  14. extern void trace_hardirqs_on(void);
  15. extern void trace_hardirqs_off(void);
  16. extern void trace_softirqs_on(unsigned long ip);
  17. extern void trace_softirqs_off(unsigned long ip);
  18. # define trace_hardirq_context(p) ((p)->hardirq_context)
  19. # define trace_softirq_context(p) ((p)->softirq_context)
  20. # define trace_hardirqs_enabled(p) ((p)->hardirqs_enabled)
  21. # define trace_softirqs_enabled(p) ((p)->softirqs_enabled)
  22. # define trace_hardirq_enter() do { current->hardirq_context++; } while (0)
  23. # define trace_hardirq_exit() do { current->hardirq_context--; } while (0)
  24. # define trace_softirq_enter() do { current->softirq_context++; } while (0)
  25. # define trace_softirq_exit() do { current->softirq_context--; } while (0)
  26. # define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
  27. #else
  28. # define trace_hardirqs_on() do { } while (0)
  29. # define trace_hardirqs_off() do { } while (0)
  30. # define trace_softirqs_on(ip) do { } while (0)
  31. # define trace_softirqs_off(ip) do { } while (0)
  32. # define trace_hardirq_context(p) 0
  33. # define trace_softirq_context(p) 0
  34. # define trace_hardirqs_enabled(p) 0
  35. # define trace_softirqs_enabled(p) 0
  36. # define trace_hardirq_enter() do { } while (0)
  37. # define trace_hardirq_exit() do { } while (0)
  38. # define trace_softirq_enter() do { } while (0)
  39. # define trace_softirq_exit() do { } while (0)
  40. # define INIT_TRACE_IRQFLAGS
  41. #endif
  42. #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
  43. #include <asm/irqflags.h>
  44. #define local_irq_enable() \
  45. do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
  46. #define local_irq_disable() \
  47. do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
  48. #define local_irq_save(flags) \
  49. do { raw_local_irq_save(flags); trace_hardirqs_off(); } while (0)
  50. #define local_irq_restore(flags) \
  51. do { \
  52. if (raw_irqs_disabled_flags(flags)) { \
  53. raw_local_irq_restore(flags); \
  54. trace_hardirqs_off(); \
  55. } else { \
  56. trace_hardirqs_on(); \
  57. raw_local_irq_restore(flags); \
  58. } \
  59. } while (0)
  60. #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
  61. /*
  62. * The local_irq_*() APIs are equal to the raw_local_irq*()
  63. * if !TRACE_IRQFLAGS.
  64. */
  65. # define raw_local_irq_disable() local_irq_disable()
  66. # define raw_local_irq_enable() local_irq_enable()
  67. # define raw_local_irq_save(flags) local_irq_save(flags)
  68. # define raw_local_irq_restore(flags) local_irq_restore(flags)
  69. #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
  70. #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
  71. #define safe_halt() \
  72. do { \
  73. trace_hardirqs_on(); \
  74. raw_safe_halt(); \
  75. } while (0)
  76. #define local_save_flags(flags) raw_local_save_flags(flags)
  77. #define irqs_disabled() \
  78. ({ \
  79. unsigned long flags; \
  80. \
  81. raw_local_save_flags(flags); \
  82. raw_irqs_disabled_flags(flags); \
  83. })
  84. #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
  85. #endif /* CONFIG_X86 */
  86. #endif