sunrpc: introduce lttng_get_clid helper
[lttng-modules.git] / instrumentation / events / lttng-module / rpc.h
CommitLineData
9f36eaed 1/* SPDX-License-Identifier: GPL-2.0 */
b87700e3 2#undef TRACE_SYSTEM
9bbf98da 3#define TRACE_SYSTEM rpc
b87700e3 4
9bbf98da
MD
5#if !defined(LTTNG_TRACE_RPC_H) || defined(TRACE_HEADER_MULTI_READ)
6#define LTTNG_TRACE_RPC_H
b87700e3 7
6ec43db8 8#include <probes/lttng-tracepoint-event.h>
b87700e3
AG
9#include <linux/sunrpc/sched.h>
10#include <linux/sunrpc/clnt.h>
b87700e3 11
b6903d57
MD
12#ifndef ONCE_LTTNG_RPC_H
13#define ONCE_LTTNG_RPC_H
14
15#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
16static inline
17int 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
28fef30f
MJ
35#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
36LTTNG_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)
b6903d57 44 ctf_integer(int, client_id, lttng_get_clid(task))
28fef30f
MJ
45 ctf_integer(int, status, task->tk_status)
46 )
47)
48
49LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
50 TP_PROTO(const struct rpc_task *task),
51
52 TP_ARGS(task)
53)
54
55LTTNG_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))
b9dbdfe2
MJ
61LTTNG_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)
b6903d57 69 ctf_integer(int, client_id, lttng_get_clid(task))
b9dbdfe2
MJ
70 ctf_integer(int, status, task->tk_status)
71 )
72)
28fef30f
MJ
73
74LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
75 TP_PROTO(struct rpc_task *task),
76
77 TP_ARGS(task)
78)
79
80LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
81 TP_PROTO(struct rpc_task *task),
82
83 TP_ARGS(task)
84)
b9dbdfe2 85#else
3bc29f0a 86LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status,
b87700e3
AG
87
88 TP_PROTO(struct rpc_task *task),
89
90 TP_ARGS(task),
91
f127e61e 92 TP_FIELDS(
fa91fcac
MD
93 ctf_integer_hex(const struct rpc_task *, task, task)
94 ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client)
f127e61e
MD
95 ctf_integer(int, status, task->tk_status)
96 )
b87700e3
AG
97)
98
3bc29f0a 99LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status,
b87700e3
AG
100 TP_PROTO(struct rpc_task *task),
101
102 TP_ARGS(task)
103)
104
3bc29f0a 105LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status,
b87700e3
AG
106 TP_PROTO(struct rpc_task *task),
107
108 TP_ARGS(task)
109)
28fef30f 110#endif
b87700e3 111
28fef30f
MJ
112#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))
113LTTNG_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))
0f891764
MJ
119LTTNG_TRACEPOINT_EVENT(rpc_connect_status,
120 TP_PROTO(const struct rpc_task *task),
121
122 TP_ARGS(task),
123
124 TP_FIELDS(
b9dbdfe2 125 ctf_integer(unsigned int, task_id, task->tk_pid)
b6903d57 126 ctf_integer(int, client_id, lttng_get_clid(task))
0f891764
MJ
127 ctf_integer(int, status, task->tk_status)
128 )
129)
28fef30f
MJ
130#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
131LTTNG_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)
b6903d57 138 ctf_integer(int, client_id, lttng_get_clid(task))
28fef30f
MJ
139 ctf_integer(int, status, status)
140 )
141)
142#else
143LTTNG_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
0f891764 155
28fef30f 156#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0))
0f891764
MJ
157LTTNG_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(
b9dbdfe2 164 ctf_integer(unsigned int, task_id, task->tk_pid)
b6903d57 165 ctf_integer(int, client_id, lttng_get_clid(task))
0f891764
MJ
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
173LTTNG_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
180LTTNG_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
187LTTNG_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
194LTTNG_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(
b9dbdfe2 201 ctf_integer(unsigned int, task_id, task->tk_pid)
b6903d57 202 ctf_integer(int, client_id, lttng_get_clid(task))
0f891764
MJ
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
211LTTNG_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
218LTTNG_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
b9dbdfe2 225#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
b9dbdfe2
MJ
226LTTNG_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)
b6903d57 234 ctf_integer(int, client_id, lttng_get_clid(task))
b9dbdfe2
MJ
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
242LTTNG_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
249LTTNG_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
256LTTNG_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
263LTTNG_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)
b6903d57 271 ctf_integer(int, client_id, lttng_get_clid(task))
b9dbdfe2
MJ
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
280LTTNG_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
287LTTNG_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
0f891764 294#else
3bc29f0a 295LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running,
b87700e3
AG
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
f127e61e 301 TP_FIELDS(
fa91fcac
MD
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)
f127e61e
MD
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 )
b87700e3
AG
309)
310
3bc29f0a 311LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_begin,
b87700e3
AG
312
313 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
314
315 TP_ARGS(clnt, task, action)
b87700e3
AG
316)
317
3bc29f0a 318LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_run_action,
b87700e3
AG
319
320 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
321
322 TP_ARGS(clnt, task, action)
b87700e3
AG
323)
324
3bc29f0a 325LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_complete,
b87700e3
AG
326
327 TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
328
329 TP_ARGS(clnt, task, action)
b87700e3
AG
330)
331
3bc29f0a 332LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued,
b87700e3
AG
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
f127e61e 338 TP_FIELDS(
fa91fcac
MD
339 ctf_integer_hex(const struct rpc_clnt *, clnt, clnt)
340 ctf_integer_hex(const struct rpc_task *, task, task)
f127e61e
MD
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 )
b87700e3
AG
347)
348
3bc29f0a 349LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_sleep,
b87700e3
AG
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)
b87700e3
AG
354)
355
3bc29f0a 356LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup,
b87700e3
AG
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)
b87700e3 361)
0f891764 362#endif
b87700e3 363
9bbf98da 364#endif /* LTTNG_TRACE_RPC_H */
b87700e3 365
6ec43db8 366#include <probes/define_trace.h>
This page took 0.048548 seconds and 4 git commands to generate.