irq.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM irq
  4. #if !defined(_TRACE_IRQ_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_IRQ_H
  6. #include <linux/tracepoint.h>
  7. struct irqaction;
  8. struct softirq_action;
  9. #define SOFTIRQ_NAME_LIST \
  10. softirq_name(HI) \
  11. softirq_name(TIMER) \
  12. softirq_name(NET_TX) \
  13. softirq_name(NET_RX) \
  14. softirq_name(BLOCK) \
  15. softirq_name(IRQ_POLL) \
  16. softirq_name(TASKLET) \
  17. softirq_name(SCHED) \
  18. softirq_name(HRTIMER) \
  19. softirq_name_end(RCU)
  20. #undef softirq_name
  21. #undef softirq_name_end
  22. #define softirq_name(sirq) TRACE_DEFINE_ENUM(sirq##_SOFTIRQ);
  23. #define softirq_name_end(sirq) TRACE_DEFINE_ENUM(sirq##_SOFTIRQ);
  24. SOFTIRQ_NAME_LIST
  25. #undef softirq_name
  26. #undef softirq_name_end
  27. #define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq },
  28. #define softirq_name_end(sirq) { sirq##_SOFTIRQ, #sirq }
  29. #define show_softirq_name(val) \
  30. __print_symbolic(val, SOFTIRQ_NAME_LIST)
  31. /**
  32. * irq_handler_entry - called immediately before the irq action handler
  33. * @irq: irq number
  34. * @action: pointer to struct irqaction
  35. *
  36. * The struct irqaction pointed to by @action contains various
  37. * information about the handler, including the device name,
  38. * @action->name, and the device id, @action->dev_id. When used in
  39. * conjunction with the irq_handler_exit tracepoint, we can figure
  40. * out irq handler latencies.
  41. */
  42. TRACE_EVENT(irq_handler_entry,
  43. TP_PROTO(int irq, struct irqaction *action),
  44. TP_ARGS(irq, action),
  45. TP_STRUCT__entry(
  46. __field( int, irq )
  47. __string( name, action->name )
  48. ),
  49. TP_fast_assign(
  50. __entry->irq = irq;
  51. __assign_str(name, action->name);
  52. ),
  53. TP_printk("irq=%d name=%s", __entry->irq, __get_str(name))
  54. );
  55. /**
  56. * irq_handler_exit - called immediately after the irq action handler returns
  57. * @irq: irq number
  58. * @action: pointer to struct irqaction
  59. * @ret: return value
  60. *
  61. * If the @ret value is set to IRQ_HANDLED, then we know that the corresponding
  62. * @action->handler successfully handled this irq. Otherwise, the irq might be
  63. * a shared irq line, or the irq was not handled successfully. Can be used in
  64. * conjunction with the irq_handler_entry to understand irq handler latencies.
  65. */
  66. TRACE_EVENT(irq_handler_exit,
  67. TP_PROTO(int irq, struct irqaction *action, int ret),
  68. TP_ARGS(irq, action, ret),
  69. TP_STRUCT__entry(
  70. __field( int, irq )
  71. __field( int, ret )
  72. ),
  73. TP_fast_assign(
  74. __entry->irq = irq;
  75. __entry->ret = ret;
  76. ),
  77. TP_printk("irq=%d ret=%s",
  78. __entry->irq, __entry->ret ? "handled" : "unhandled")
  79. );
  80. DECLARE_EVENT_CLASS(softirq,
  81. TP_PROTO(unsigned int vec_nr),
  82. TP_ARGS(vec_nr),
  83. TP_STRUCT__entry(
  84. __field( unsigned int, vec )
  85. ),
  86. TP_fast_assign(
  87. __entry->vec = vec_nr;
  88. ),
  89. TP_printk("vec=%u [action=%s]", __entry->vec,
  90. show_softirq_name(__entry->vec))
  91. );
  92. /**
  93. * softirq_entry - called immediately before the softirq handler
  94. * @vec_nr: softirq vector number
  95. *
  96. * When used in combination with the softirq_exit tracepoint
  97. * we can determine the softirq handler routine.
  98. */
  99. DEFINE_EVENT(softirq, softirq_entry,
  100. TP_PROTO(unsigned int vec_nr),
  101. TP_ARGS(vec_nr)
  102. );
  103. /**
  104. * softirq_exit - called immediately after the softirq handler returns
  105. * @vec_nr: softirq vector number
  106. *
  107. * When used in combination with the softirq_entry tracepoint
  108. * we can determine the softirq handler routine.
  109. */
  110. DEFINE_EVENT(softirq, softirq_exit,
  111. TP_PROTO(unsigned int vec_nr),
  112. TP_ARGS(vec_nr)
  113. );
  114. /**
  115. * softirq_raise - called immediately when a softirq is raised
  116. * @vec_nr: softirq vector number
  117. *
  118. * When used in combination with the softirq_entry tracepoint
  119. * we can determine the softirq raise to run latency.
  120. */
  121. DEFINE_EVENT(softirq, softirq_raise,
  122. TP_PROTO(unsigned int vec_nr),
  123. TP_ARGS(vec_nr)
  124. );
  125. DECLARE_EVENT_CLASS(tasklet,
  126. TP_PROTO(void *func),
  127. TP_ARGS(func),
  128. TP_STRUCT__entry(
  129. __field( void *, func)
  130. ),
  131. TP_fast_assign(
  132. __entry->func = func;
  133. ),
  134. TP_printk("function=%ps", __entry->func)
  135. );
  136. /**
  137. * tasklet_entry - called immediately before the tasklet is run
  138. * @func: tasklet callback or function being run
  139. *
  140. * Used to find individual tasklet execution time
  141. */
  142. DEFINE_EVENT(tasklet, tasklet_entry,
  143. TP_PROTO(void *func),
  144. TP_ARGS(func)
  145. );
  146. /**
  147. * tasklet_exit - called immediately after the tasklet is run
  148. * @func: tasklet callback or function being run
  149. *
  150. * Used to find individual tasklet execution time
  151. */
  152. DEFINE_EVENT(tasklet, tasklet_exit,
  153. TP_PROTO(void *func),
  154. TP_ARGS(func)
  155. );
  156. #endif /* _TRACE_IRQ_H */
  157. /* This part must be outside protection */
  158. #include <trace/define_trace.h>