workqueue.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. DECLARE_EVENT_CLASS(workqueue_work,
  9. TP_PROTO(struct work_struct *work),
  10. TP_ARGS(work),
  11. TP_STRUCT__entry(
  12. __field( void *, work )
  13. ),
  14. TP_fast_assign(
  15. __entry->work = work;
  16. ),
  17. TP_printk("work struct %p", __entry->work)
  18. );
  19. struct pool_workqueue;
  20. /**
  21. * workqueue_queue_work - called when a work gets queued
  22. * @req_cpu: the requested cpu
  23. * @pwq: pointer to struct pool_workqueue
  24. * @work: pointer to struct work_struct
  25. *
  26. * This event occurs when a work is queued immediately or once a
  27. * delayed work is actually queued on a workqueue (ie: once the delay
  28. * has been reached).
  29. */
  30. TRACE_EVENT(workqueue_queue_work,
  31. TP_PROTO(unsigned int req_cpu, struct pool_workqueue *pwq,
  32. struct work_struct *work),
  33. TP_ARGS(req_cpu, pwq, work),
  34. TP_STRUCT__entry(
  35. __field( void *, work )
  36. __field( void *, function)
  37. __field( void *, workqueue)
  38. __field( unsigned int, req_cpu )
  39. __field( unsigned int, cpu )
  40. ),
  41. TP_fast_assign(
  42. __entry->work = work;
  43. __entry->function = work->func;
  44. __entry->workqueue = pwq->wq;
  45. __entry->req_cpu = req_cpu;
  46. __entry->cpu = pwq->pool->cpu;
  47. ),
  48. TP_printk("work struct=%p function=%pf workqueue=%p req_cpu=%u cpu=%u",
  49. __entry->work, __entry->function, __entry->workqueue,
  50. __entry->req_cpu, __entry->cpu)
  51. );
  52. /**
  53. * workqueue_activate_work - called when a work gets activated
  54. * @work: pointer to struct work_struct
  55. *
  56. * This event occurs when a queued work is put on the active queue,
  57. * which happens immediately after queueing unless @max_active limit
  58. * is reached.
  59. */
  60. DEFINE_EVENT(workqueue_work, workqueue_activate_work,
  61. TP_PROTO(struct work_struct *work),
  62. TP_ARGS(work)
  63. );
  64. /**
  65. * workqueue_execute_start - called immediately before the workqueue callback
  66. * @work: pointer to struct work_struct
  67. *
  68. * Allows to track workqueue execution.
  69. */
  70. TRACE_EVENT(workqueue_execute_start,
  71. TP_PROTO(struct work_struct *work),
  72. TP_ARGS(work),
  73. TP_STRUCT__entry(
  74. __field( void *, work )
  75. __field( void *, function)
  76. ),
  77. TP_fast_assign(
  78. __entry->work = work;
  79. __entry->function = work->func;
  80. ),
  81. TP_printk("work struct %p: function %pf", __entry->work, __entry->function)
  82. );
  83. /**
  84. * workqueue_execute_end - called immediately after the workqueue callback
  85. * @work: pointer to struct work_struct
  86. *
  87. * Allows to track workqueue execution.
  88. */
  89. DEFINE_EVENT(workqueue_work, workqueue_execute_end,
  90. TP_PROTO(struct work_struct *work),
  91. TP_ARGS(work)
  92. );
  93. #endif /* _TRACE_WORKQUEUE_H */
  94. /* This part must be outside protection */
  95. #include <trace/define_trace.h>