workqueue.h 2.7 KB

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