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