8393a3311440e47cbece61a92e3a9d583b3236e4
[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_STRUCT__entry(
28 __field( void *, work )
29 ),
30
31 TP_fast_assign(
32 tp_assign(work, work)
33 ),
34
35 TP_printk("work struct %p", __entry->work)
36 )
37
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
39 /**
40 * workqueue_queue_work - called when a work gets queued
41 * @req_cpu: the requested cpu
42 * @cwq: pointer to struct cpu_workqueue_struct
43 * @work: pointer to struct work_struct
44 *
45 * This event occurs when a work is queued immediately or once a
46 * delayed work is actually queued on a workqueue (ie: once the delay
47 * has been reached).
48 */
49 LTTNG_TRACEPOINT_EVENT(workqueue_queue_work,
50
51 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
52 TP_PROTO(unsigned int req_cpu, struct pool_workqueue *pwq,
53 struct work_struct *work),
54
55 TP_ARGS(req_cpu, pwq, work),
56 #else
57 TP_PROTO(unsigned int req_cpu, struct cpu_workqueue_struct *cwq,
58 struct work_struct *work),
59
60 TP_ARGS(req_cpu, cwq, work),
61 #endif
62
63 TP_STRUCT__entry(
64 __field( void *, work )
65 __field( void *, function)
66 __field( unsigned int, req_cpu )
67 ),
68
69 TP_fast_assign(
70 tp_assign(work, work)
71 tp_assign(function, work->func)
72 tp_assign(req_cpu, req_cpu)
73 ),
74
75 TP_printk("work struct=%p function=%pf req_cpu=%u",
76 __entry->work, __entry->function,
77 __entry->req_cpu)
78 )
79
80 /**
81 * workqueue_activate_work - called when a work gets activated
82 * @work: pointer to struct work_struct
83 *
84 * This event occurs when a queued work is put on the active queue,
85 * which happens immediately after queueing unless @max_active limit
86 * is reached.
87 */
88 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_activate_work,
89
90 TP_PROTO(struct work_struct *work),
91
92 TP_ARGS(work)
93 )
94 #endif
95
96 /**
97 * workqueue_execute_start - called immediately before the workqueue callback
98 * @work: pointer to struct work_struct
99 *
100 * Allows to track workqueue execution.
101 */
102 LTTNG_TRACEPOINT_EVENT(workqueue_execute_start,
103
104 TP_PROTO(struct work_struct *work),
105
106 TP_ARGS(work),
107
108 TP_STRUCT__entry(
109 __field( void *, work )
110 __field( void *, function)
111 ),
112
113 TP_fast_assign(
114 tp_assign(work, work)
115 tp_assign(function, work->func)
116 ),
117
118 TP_printk("work struct %p: function %pf", __entry->work, __entry->function)
119 )
120
121 /**
122 * workqueue_execute_end - called immediately after the workqueue callback
123 * @work: pointer to struct work_struct
124 *
125 * Allows to track workqueue execution.
126 */
127 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_execute_end,
128
129 TP_PROTO(struct work_struct *work),
130
131 TP_ARGS(work)
132 )
133
134 #else
135
136 LTTNG_TRACEPOINT_EVENT_CLASS(workqueue,
137
138 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
139
140 TP_ARGS(wq_thread, work),
141
142 TP_STRUCT__entry(
143 __array(char, thread_comm, TASK_COMM_LEN)
144 __field(pid_t, thread_pid)
145 __field(work_func_t, func)
146 ),
147
148 TP_fast_assign(
149 tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
150 tp_assign(thread_pid, wq_thread->pid)
151 tp_assign(func, work->func)
152 ),
153
154 TP_printk("thread=%s:%d func=%pf", __entry->thread_comm,
155 __entry->thread_pid, __entry->func)
156 )
157
158 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_insertion,
159
160 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
161
162 TP_ARGS(wq_thread, work)
163 )
164
165 LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_execution,
166
167 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
168
169 TP_ARGS(wq_thread, work)
170 )
171
172 /* Trace the creation of one workqueue thread on a cpu */
173 LTTNG_TRACEPOINT_EVENT(workqueue_creation,
174
175 TP_PROTO(struct task_struct *wq_thread, int cpu),
176
177 TP_ARGS(wq_thread, cpu),
178
179 TP_STRUCT__entry(
180 __array(char, thread_comm, TASK_COMM_LEN)
181 __field(pid_t, thread_pid)
182 __field(int, cpu)
183 ),
184
185 TP_fast_assign(
186 tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
187 tp_assign(thread_pid, wq_thread->pid)
188 tp_assign(cpu, cpu)
189 ),
190
191 TP_printk("thread=%s:%d cpu=%d", __entry->thread_comm,
192 __entry->thread_pid, __entry->cpu)
193 )
194
195 LTTNG_TRACEPOINT_EVENT(workqueue_destruction,
196
197 TP_PROTO(struct task_struct *wq_thread),
198
199 TP_ARGS(wq_thread),
200
201 TP_STRUCT__entry(
202 __array(char, thread_comm, TASK_COMM_LEN)
203 __field(pid_t, thread_pid)
204 ),
205
206 TP_fast_assign(
207 tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
208 tp_assign(thread_pid, wq_thread->pid)
209 ),
210
211 TP_printk("thread=%s:%d", __entry->thread_comm, __entry->thread_pid)
212 )
213
214 #endif
215
216 #endif /* LTTNG_TRACE_WORKQUEUE_H */
217
218 /* This part must be outside protection */
219 #include "../../../probes/define_trace.h"
This page took 0.041937 seconds and 3 git commands to generate.