workqueue.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM workqueue
  4. #if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_WORKQUEUE_H
  6. #include <linux/tracepoint.h>
  7. #include <linux/workqueue.h>
  8. struct pool_workqueue;
  9. /**
  10. * workqueue_queue_work - called when a work gets queued
  11. * @req_cpu: the requested cpu
  12. * @pwq: pointer to struct pool_workqueue
  13. * @work: pointer to struct work_struct
  14. *
  15. * This event occurs when a work is queued immediately or once a
  16. * delayed work is actually queued on a workqueue (ie: once the delay
  17. * has been reached).
  18. */
  19. TRACE_EVENT(workqueue_queue_work,
  20. TP_PROTO(int req_cpu, struct pool_workqueue *pwq,
  21. struct work_struct *work),
  22. TP_ARGS(req_cpu, pwq, work),
  23. TP_STRUCT__entry(
  24. __field( void *, work )
  25. __field( void *, function)
  26. __string( workqueue, pwq->wq->name)
  27. __field( int, req_cpu )
  28. __field( int, cpu )
  29. ),
  30. TP_fast_assign(
  31. __entry->work = work;
  32. __entry->function = work->func;
  33. __assign_str(workqueue, pwq->wq->name);
  34. __entry->req_cpu = req_cpu;
  35. __entry->cpu = pwq->pool->cpu;
  36. ),
  37. TP_printk("work struct=%p function=%ps workqueue=%s req_cpu=%d cpu=%d",
  38. __entry->work, __entry->function, __get_str(workqueue),
  39. __entry->req_cpu, __entry->cpu)
  40. );
  41. /**
  42. * workqueue_activate_work - called when a work gets activated
  43. * @work: pointer to struct work_struct
  44. *
  45. * This event occurs when a queued work is put on the active queue,
  46. * which happens immediately after queueing unless @max_active limit
  47. * is reached.
  48. */
  49. TRACE_EVENT(workqueue_activate_work,
  50. TP_PROTO(struct work_struct *work),
  51. TP_ARGS(work),
  52. TP_STRUCT__entry(
  53. __field( void *, work )
  54. ),
  55. TP_fast_assign(
  56. __entry->work = work;
  57. ),
  58. TP_printk("work struct %p", __entry->work)
  59. );
  60. /**
  61. * workqueue_execute_start - called immediately before the workqueue callback
  62. * @work: pointer to struct work_struct
  63. *
  64. * Allows to track workqueue execution.
  65. */
  66. TRACE_EVENT(workqueue_execute_start,
  67. TP_PROTO(struct work_struct *work),
  68. TP_ARGS(work),
  69. TP_STRUCT__entry(
  70. __field( void *, work )
  71. __field( void *, function)
  72. ),
  73. TP_fast_assign(
  74. __entry->work = work;
  75. __entry->function = work->func;
  76. ),
  77. TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
  78. );
  79. /**
  80. * workqueue_execute_end - called immediately after the workqueue callback
  81. * @work: pointer to struct work_struct
  82. * @function: pointer to worker function
  83. *
  84. * Allows to track workqueue execution.
  85. */
  86. TRACE_EVENT(workqueue_execute_end,
  87. TP_PROTO(struct work_struct *work, work_func_t function),
  88. TP_ARGS(work, function),
  89. TP_STRUCT__entry(
  90. __field( void *, work )
  91. __field( void *, function)
  92. ),
  93. TP_fast_assign(
  94. __entry->work = work;
  95. __entry->function = function;
  96. ),
  97. TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
  98. );
  99. #endif /* _TRACE_WORKQUEUE_H */
  100. /* This part must be outside protection */
  101. #include <trace/define_trace.h>