hardirq.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef LINUX_HARDIRQ_H
  2. #define LINUX_HARDIRQ_H
  3. #include <linux/preempt_mask.h>
  4. #include <linux/lockdep.h>
  5. #include <linux/ftrace_irq.h>
  6. #include <linux/vtime.h>
  7. #if defined(CONFIG_SMP) || defined(CONFIG_GENERIC_HARDIRQS)
  8. extern void synchronize_irq(unsigned int irq);
  9. #else
  10. # define synchronize_irq(irq) barrier()
  11. #endif
  12. #if defined(CONFIG_TINY_RCU)
  13. static inline void rcu_nmi_enter(void)
  14. {
  15. }
  16. static inline void rcu_nmi_exit(void)
  17. {
  18. }
  19. #else
  20. extern void rcu_nmi_enter(void);
  21. extern void rcu_nmi_exit(void);
  22. #endif
  23. /*
  24. * It is safe to do non-atomic ops on ->hardirq_context,
  25. * because NMI handlers may not preempt and the ops are
  26. * always balanced, so the interrupted value of ->hardirq_context
  27. * will always be restored.
  28. */
  29. #define __irq_enter() \
  30. do { \
  31. account_irq_enter_time(current); \
  32. add_preempt_count(HARDIRQ_OFFSET); \
  33. trace_hardirq_enter(); \
  34. } while (0)
  35. /*
  36. * Enter irq context (on NO_HZ, update jiffies):
  37. */
  38. extern void irq_enter(void);
  39. /*
  40. * Exit irq context without processing softirqs:
  41. */
  42. #define __irq_exit() \
  43. do { \
  44. trace_hardirq_exit(); \
  45. account_irq_exit_time(current); \
  46. sub_preempt_count(HARDIRQ_OFFSET); \
  47. } while (0)
  48. /*
  49. * Exit irq context and process softirqs if needed:
  50. */
  51. extern void irq_exit(void);
  52. #define nmi_enter() \
  53. do { \
  54. lockdep_off(); \
  55. ftrace_nmi_enter(); \
  56. BUG_ON(in_nmi()); \
  57. add_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \
  58. rcu_nmi_enter(); \
  59. trace_hardirq_enter(); \
  60. } while (0)
  61. #define nmi_exit() \
  62. do { \
  63. trace_hardirq_exit(); \
  64. rcu_nmi_exit(); \
  65. BUG_ON(!in_nmi()); \
  66. sub_preempt_count(NMI_OFFSET + HARDIRQ_OFFSET); \
  67. ftrace_nmi_exit(); \
  68. lockdep_on(); \
  69. } while (0)
  70. #endif /* LINUX_HARDIRQ_H */