Rename LTTng instrumentation macros
[lttng-modules.git] / instrumentation / events / lttng-module / workqueue.h
CommitLineData
b87700e3
AG
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM workqueue
3
3bc29f0a
MD
4#if !defined(LTTNG_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
5#define LTTNG_TRACE_WORKQUEUE_H
b87700e3 6
3bc29f0a 7#include "../../../probes/lttng-tracepoint-event.h"
b87700e3
AG
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
16struct worker;
17struct global_cwq;
18
b87700e3
AG
19#endif
20
3bc29f0a 21LTTNG_TRACEPOINT_EVENT_CLASS(workqueue_work,
b87700e3
AG
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 */
3bc29f0a 49LTTNG_TRACEPOINT_EVENT(workqueue_queue_work,
b87700e3 50
20008d8c
MD
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
b87700e3
AG
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),
20008d8c 61#endif
b87700e3
AG
62
63 TP_STRUCT__entry(
64 __field( void *, work )
65 __field( void *, function)
b87700e3 66 __field( unsigned int, req_cpu )
b87700e3
AG
67 ),
68
69 TP_fast_assign(
70 tp_assign(work, work)
71 tp_assign(function, work->func)
b87700e3 72 tp_assign(req_cpu, req_cpu)
b87700e3
AG
73 ),
74
20008d8c
MD
75 TP_printk("work struct=%p function=%pf req_cpu=%u",
76 __entry->work, __entry->function,
77 __entry->req_cpu)
b87700e3
AG
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 */
3bc29f0a 88LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_activate_work,
b87700e3
AG
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 */
3bc29f0a 102LTTNG_TRACEPOINT_EVENT(workqueue_execute_start,
b87700e3
AG
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 */
3bc29f0a 127LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue_work, workqueue_execute_end,
b87700e3
AG
128
129 TP_PROTO(struct work_struct *work),
130
131 TP_ARGS(work)
132)
133
134#else
135
3bc29f0a 136LTTNG_TRACEPOINT_EVENT_CLASS(workqueue,
b87700e3
AG
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
3bc29f0a 158LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_insertion,
b87700e3
AG
159
160 TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
161
162 TP_ARGS(wq_thread, work)
163)
164
3bc29f0a 165LTTNG_TRACEPOINT_EVENT_INSTANCE(workqueue, workqueue_execution,
b87700e3
AG
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 */
3bc29f0a 173LTTNG_TRACEPOINT_EVENT(workqueue_creation,
b87700e3
AG
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
3bc29f0a 195LTTNG_TRACEPOINT_EVENT(workqueue_destruction,
b87700e3
AG
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
3bc29f0a 216#endif /* LTTNG_TRACE_WORKQUEUE_H */
b87700e3
AG
217
218/* This part must be outside protection */
219#include "../../../probes/define_trace.h"
This page took 0.041555 seconds and 4 git commands to generate.