sunrpc: introduce lttng_get_clid helper
[lttng-modules.git] / instrumentation / events / lttng-module / rpc.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM rpc
4
5 #if !defined(LTTNG_TRACE_RPC_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_RPC_H
7
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/sunrpc/sched.h>
10 #include <linux/sunrpc/clnt.h>
11
12 #ifndef ONCE_LTTNG_RPC_H
13 #define ONCE_LTTNG_RPC_H
14
15 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16 static inline
17 int lttng_get_clid(const struct rpc_task *task)
18 {
19 struct rpc_clnt *tk_client;
20
21 tk_client = task->tk_client;
22 if (!tk_client)
23 return -1;
24 /*
25 * The cl_clid field is always initialized to positive signed
26 * integers. Negative signed integer values are treated as
27 * errors.
28 */
29 return (int) tk_client->cl_clid;
30 }
31 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
32
33 #endif /* ONCE_LTTNG_RPC_H */
34
35 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
36 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
37
38 TP_PROTO(const struct rpc_task *task),
39
40 TP_ARGS(task),
41
42 TP_FIELDS(
43 ctf_integer(unsigned int, task_id, task->tk_pid)
44 ctf_integer(int, client_id, lttng_get_clid(task))
45 ctf_integer(int, status, task->tk_status)
46 )
47 )
48
49 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
50 TP_PROTO(const struct rpc_task *task),
51
52 TP_ARGS(task)
53 )
54
55 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
56 TP_PROTO(const struct rpc_task *task),
57
58 TP_ARGS(task)
59 )
60 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
61 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
62
63 TP_PROTO(struct rpc_task *task),
64
65 TP_ARGS(task),
66
67 TP_FIELDS(
68 ctf_integer(unsigned int, task_id, task->tk_pid)
69 ctf_integer(int, client_id, lttng_get_clid(task))
70 ctf_integer(int, status, task->tk_status)
71 )
72 )
73
74 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
75 TP_PROTO(struct rpc_task *task),
76
77 TP_ARGS(task)
78 )
79
80 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
81 TP_PROTO(struct rpc_task *task),
82
83 TP_ARGS(task)
84 )
85 #else
86 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
87
88 TP_PROTO(struct rpc_task *task),
89
90 TP_ARGS(task),
91
92 TP_FIELDS(
93 ctf_integer_hex(const struct rpc_task *, task, task)
94 ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client)
95 ctf_integer(int, status, task->tk_status)
96 )
97 )
98
99 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
100 TP_PROTO(struct rpc_task *task),
101
102 TP_ARGS(task)
103 )
104
105 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
106 TP_PROTO(struct rpc_task *task),
107
108 TP_ARGS(task)
109 )
110 #endif
111
112 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
113 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_connect_status,
114 TP_PROTO(const struct rpc_task *task),
115
116 TP_ARGS(task)
117 )
118 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
119 LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
120 TP_PROTO(const struct rpc_task *task),
121
122 TP_ARGS(task),
123
124 TP_FIELDS(
125 ctf_integer(unsigned int, task_id, task->tk_pid)
126 ctf_integer(int, client_id, lttng_get_clid(task))
127 ctf_integer(int, status, task->tk_status)
128 )
129 )
130 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
131 LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
132 TP_PROTO(struct rpc_task *task, int status),
133
134 TP_ARGS(task, status),
135
136 TP_FIELDS(
137 ctf_integer(unsigned int, task_id, task->tk_pid)
138 ctf_integer(int, client_id, lttng_get_clid(task))
139 ctf_integer(int, status, status)
140 )
141 )
142 #else
143 LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
144 TP_PROTO(struct rpc_task *task, int status),
145
146 TP_ARGS(task, status),
147
148 TP_FIELDS(
149 ctf_integer_hex(const struct rpc_task *, task, task)
150 ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client)
151 ctf_integer(int, status, status)
152 )
153 )
154 #endif
155
156 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
157 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
158
159 TP_PROTO(const struct rpc_task *task, const void *action),
160
161 TP_ARGS(task, action),
162
163 TP_FIELDS(
164 ctf_integer(unsigned int, task_id, task->tk_pid)
165 ctf_integer(int, client_id, lttng_get_clid(task))
166 ctf_integer_hex(const void *, action, action)
167 ctf_integer(unsigned long, runstate, task->tk_runstate)
168 ctf_integer(int, status, task->tk_status)
169 ctf_integer(unsigned short, flags, task->tk_flags)
170 )
171 )
172
173 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_begin,
174
175 TP_PROTO(const struct rpc_task *task, const void *action),
176
177 TP_ARGS(task, action)
178 )
179
180 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_run_action,
181
182 TP_PROTO(const struct rpc_task *task, const void *action),
183
184 TP_ARGS(task, action)
185 )
186
187 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_complete,
188
189 TP_PROTO(const struct rpc_task *task, const void *action),
190
191 TP_ARGS(task, action)
192 )
193
194 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
195
196 TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
197
198 TP_ARGS(task, q),
199
200 TP_FIELDS(
201 ctf_integer(unsigned int, task_id, task->tk_pid)
202 ctf_integer(int, client_id, lttng_get_clid(task))
203 ctf_integer(unsigned long, timeout, task->tk_timeout)
204 ctf_integer(unsigned long, runstate, task->tk_runstate)
205 ctf_integer(int, status, task->tk_status)
206 ctf_integer(unsigned short, flags, task->tk_flags)
207 ctf_string(q_name, rpc_qname(q))
208 )
209 )
210
211 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_sleep,
212
213 TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
214
215 TP_ARGS(task, q)
216 )
217
218 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
219
220 TP_PROTO(const struct rpc_task *task, const struct rpc_wait_queue *q),
221
222 TP_ARGS(task, q)
223 )
224
225 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
226 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
227
228 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
229
230 TP_ARGS(clnt, task, action),
231
232 TP_FIELDS(
233 ctf_integer(unsigned int, task_id, task->tk_pid)
234 ctf_integer(int, client_id, lttng_get_clid(task))
235 ctf_integer_hex(const void *, action, action)
236 ctf_integer(unsigned long, runstate, task->tk_runstate)
237 ctf_integer(int, status, task->tk_status)
238 ctf_integer(unsigned short, flags, task->tk_flags)
239 )
240 )
241
242 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_begin,
243
244 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
245
246 TP_ARGS(clnt, task, action)
247 )
248
249 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_run_action,
250
251 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
252
253 TP_ARGS(clnt, task, action)
254 )
255
256 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_complete,
257
258 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
259
260 TP_ARGS(clnt, task, action)
261 )
262
263 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
264
265 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
266
267 TP_ARGS(clnt, task, q),
268
269 TP_FIELDS(
270 ctf_integer(unsigned int, task_id, task->tk_pid)
271 ctf_integer(int, client_id, lttng_get_clid(task))
272 ctf_integer(unsigned long, timeout, task->tk_timeout)
273 ctf_integer(unsigned long, runstate, task->tk_runstate)
274 ctf_integer(int, status, task->tk_status)
275 ctf_integer(unsigned short, flags, task->tk_flags)
276 ctf_string(q_name, rpc_qname(q))
277 )
278 )
279
280 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_sleep,
281
282 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
283
284 TP_ARGS(clnt, task, q)
285 )
286
287 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
288
289 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
290
291 TP_ARGS(clnt, task, q)
292 )
293
294 #else
295 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
296
297 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
298
299 TP_ARGS(clnt, task, action),
300
301 TP_FIELDS(
302 ctf_integer_hex(const struct rpc_clnt *, clnt, clnt)
303 ctf_integer_hex(const struct rpc_task *, task, task)
304 ctf_integer_hex(const void *, action, action)
305 ctf_integer(unsigned long, runstate, task->tk_runstate)
306 ctf_integer(int, status, task->tk_status)
307 ctf_integer(unsigned short, flags, task->tk_flags)
308 )
309 )
310
311 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_begin,
312
313 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
314
315 TP_ARGS(clnt, task, action)
316 )
317
318 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_run_action,
319
320 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
321
322 TP_ARGS(clnt, task, action)
323 )
324
325 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_complete,
326
327 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
328
329 TP_ARGS(clnt, task, action)
330 )
331
332 LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
333
334 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
335
336 TP_ARGS(clnt, task, q),
337
338 TP_FIELDS(
339 ctf_integer_hex(const struct rpc_clnt *, clnt, clnt)
340 ctf_integer_hex(const struct rpc_task *, task, task)
341 ctf_integer(unsigned long, timeout, task->tk_timeout)
342 ctf_integer(unsigned long, runstate, task->tk_runstate)
343 ctf_integer(int, status, task->tk_status)
344 ctf_integer(unsigned short, flags, task->tk_flags)
345 ctf_string(q_name, rpc_qname(q))
346 )
347 )
348
349 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_sleep,
350
351 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
352
353 TP_ARGS(clnt, task, q)
354 )
355
356 LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
357
358 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
359
360 TP_ARGS(clnt, task, q)
361 )
362 #endif
363
364 #endif /* LTTNG_TRACE_RPC_H */
365
366 #include <probes/define_trace.h>
This page took 0.04002 seconds and 4 git commands to generate.