fix: workqueue: add worker function to workqueue_execute_end tracepoint (v5.6)
[lttng-modules.git] / instrumentation / events / lttng-module / workqueue.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM workqueue
3
4 #if !defined(LTTNG_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_WORKQUEUE_H
6
7 #include <probes/lttng-tracepoint-event.h>
8 #include <linux/workqueue.h>
9 #include <linux/version.h>
10
11 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
12
13 #ifndef _TRACE_WORKQUEUE_DEF_
14 #define _TRACE_WORKQUEUE_DEF_
15
16 struct worker;
17 struct global_cwq;
18
19 #endif
20
21 LTTNG_TRACEPOINT_EVENT_CLASS(workqueue_work,
22
23 TP_PROTO(struct work_struct *work),
24
25 TP_ARGS(work),
26
27 TP_FIELDS(
28 ctf_integer_hex(void *, work, work)
29 )
30 )
31
32 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
33 /**
34 * workqueue_queue_work - called when a work gets queued
35 * @req_cpu: the requested cpu
36 * @cwq: pointer to struct cpu_workqueue_struct
37 * @work: pointer to struct work_struct
38 *
39 * This event occurs when a work is queued immediately or once a
40 * delayed work is actually queued on a workqueue (ie: once the delay
41 * has been reached).
42 */
43 LTTNG_TRACEPOINT_EVENT(workqueue_queue_work,
44
45 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
46 TP_PROTO(unsigned int req_cpu, struct pool_workqueue *pwq,
47 struct work_struct *work),
48
49 TP_ARGS(req_cpu, pwq, work),
50 #else
51 TP_PROTO(unsigned int req_cpu, struct cpu_workqueue_struct *cwq,
52 struct work_struct *work),
53
54 TP_ARGS(req_cpu, cwq, work),
55 #endif
56
57 TP_FIELDS(
58 ctf_integer_hex(void *, work, work)
59 ctf_integer_hex(void *, function, work->func)
60 ctf_integer(unsigned int, req_cpu, req_cpu)
61 )
62 )
63
64 /**
65 * workqueue_activate_work - called when a work gets activated
66 * @work: pointer to struct work_struct
67 *
68 * This event occurs when a queued work is put on the active queue,
69 * which happens immediately after queueing unless @max_active limit
70 * is reached.
71 */
72 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_activate_work,
73
74 TP_PROTO(struct work_struct *work),
75
76 TP_ARGS(work)
77 )
78 #endif
79
80 /**
81 * workqueue_execute_start - called immediately before the workqueue callback
82 * @work: pointer to struct work_struct
83 *
84 * Allows to track workqueue execution.
85 */
86 LTTNG_TRACEPOINT_EVENT(workqueue_execute_start,
87
88 TP_PROTO(struct work_struct *work),
89
90 TP_ARGS(work),
91
92 TP_FIELDS(
93 ctf_integer_hex(void *, work, work)
94 ctf_integer_hex(void *, function, work->func)
95 )
96 )
97
98 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
99 /**
100 * workqueue_execute_end - called immediately after the workqueue callback
101 * @work: pointer to struct work_struct
102 * @function: pointer to worker function
103 *
104 * Allows to track workqueue execution.
105 */
106 LTTNG_TRACEPOINT_EVENT(workqueue_execute_end,
107
108 TP_PROTO(struct work_struct *work, work_func_t function),
109
110 TP_ARGS(work, function),
111
112 TP_FIELDS(
113 ctf_integer_hex(void *, work, work)
114 ctf_integer_hex(void *, function, function)
115 )
116 )
117 #else
118 /**
119 * workqueue_execute_end - called immediately after the workqueue callback
120 * @work: pointer to struct work_struct
121 *
122 * Allows to track workqueue execution.
123 */
124 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_execute_end,
125
126 TP_PROTO(struct work_struct *work),
127
128 TP_ARGS(work)
129 )
130 #endif
131
132 #else
133
134 LTTNG_TRACEPOINT_EVENT_CLASS(workqueue,
135
136 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
137
138 TP_ARGS(wq_thread, work),
139
140 TP_FIELDS(
141 ctf_array(char, thread_comm, wq_thread->comm, TASK_COMM_LEN)
142 ctf_integer(pid_t, thread_pid, wq_thread->pid)
143 ctf_integer_hex(work_func_t, func, work->func)
144 )
145 )
146
147 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_insertion,
148
149 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
150
151 TP_ARGS(wq_thread, work)
152 )
153
154 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_execution,
155
156 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
157
158 TP_ARGS(wq_thread, work)
159 )
160
161 /* Trace the creation of one workqueue thread on a cpu */
162 LTTNG_TRACEPOINT_EVENT(workqueue_creation,
163
164 TP_PROTO(struct task_struct *wq_thread, int cpu),
165
166 TP_ARGS(wq_thread, cpu),
167
168 TP_FIELDS(
169 ctf_array(char, thread_comm, wq_thread->comm, TASK_COMM_LEN)
170 ctf_integer(pid_t, thread_pid, wq_thread->pid)
171 ctf_integer(int, cpu, cpu)
172 )
173 )
174
175 LTTNG_TRACEPOINT_EVENT(workqueue_destruction,
176
177 TP_PROTO(struct task_struct *wq_thread),
178
179 TP_ARGS(wq_thread),
180
181 TP_FIELDS(
182 ctf_array(char, thread_comm, wq_thread->comm, TASK_COMM_LEN)
183 ctf_integer(pid_t, thread_pid, wq_thread->pid)
184 )
185 )
186
187 #endif
188
189 #endif /* LTTNG_TRACE_WORKQUEUE_H */
190
191 /* This part must be outside protection */
192 #include <probes/define_trace.h>
This page took 0.032287 seconds and 4 git commands to generate.