hardirq.h 1.7 KB

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