Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
e54456f5 MD |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM timer | |
4 | ||
3bc29f0a MD |
5 | #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_TIMER_H | |
e54456f5 | 7 | |
3b4aafcb | 8 | #include <lttng/tracepoint-event.h> |
e54456f5 MD |
9 | |
10 | #ifndef _TRACE_TIMER_DEF_ | |
11 | #define _TRACE_TIMER_DEF_ | |
12 | #include <linux/hrtimer.h> | |
13 | #include <linux/timer.h> | |
5f4c791e | 14 | #include <lttng/kernel-version.h> |
3a523f5b MD |
15 | |
16 | struct timer_list; | |
17 | ||
e54456f5 MD |
18 | #endif /* _TRACE_TIMER_DEF_ */ |
19 | ||
5f4c791e | 20 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) |
507143bc | 21 | #define lttng_ktime_get_tv64(kt) (kt) |
5f4c791e | 22 | #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */ |
507143bc | 23 | #define lttng_ktime_get_tv64(kt) ((kt).tv64) |
5f4c791e | 24 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */ |
507143bc | 25 | |
3bc29f0a | 26 | LTTNG_TRACEPOINT_EVENT_CLASS(timer_class, |
e54456f5 MD |
27 | |
28 | TP_PROTO(struct timer_list *timer), | |
29 | ||
30 | TP_ARGS(timer), | |
31 | ||
f127e61e | 32 | TP_FIELDS( |
fa91fcac | 33 | ctf_integer_hex(void *, timer, timer) |
f127e61e | 34 | ) |
e54456f5 MD |
35 | ) |
36 | ||
37 | /** | |
38 | * timer_init - called when the timer is initialized | |
39 | * @timer: pointer to struct timer_list | |
40 | */ | |
3bc29f0a | 41 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init, |
e54456f5 MD |
42 | |
43 | TP_PROTO(struct timer_list *timer), | |
44 | ||
45 | TP_ARGS(timer) | |
46 | ) | |
47 | ||
f4c1678d KS |
48 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0)) |
49 | /** | |
50 | * timer_start - called when the timer is started | |
51 | * @timer: pointer to struct timer_list | |
52 | * @expires: the timers expiry time | |
53 | * @flags: the timers expiry time | |
54 | */ | |
55 | LTTNG_TRACEPOINT_EVENT(timer_start, | |
56 | ||
57 | TP_PROTO(struct timer_list *timer, unsigned long bucket_expiry), | |
58 | ||
59 | TP_ARGS(timer, bucket_expiry), | |
60 | ||
61 | TP_FIELDS( | |
62 | ctf_integer_hex(void *, timer, timer) | |
63 | ctf_integer_hex(void *, function, timer->function) | |
64 | ctf_integer(unsigned long, expires, timer->expires) | |
65 | ctf_integer(unsigned long, bucket_expiry, bucket_expiry) | |
66 | ctf_integer(unsigned long, now, jiffies) | |
67 | ctf_integer(unsigned int, flags, timer->flags) | |
68 | ) | |
69 | ) | |
70 | #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0) || \ | |
a2e303cc | 71 | LTTNG_RHEL_KERNEL_RANGE(3,10,0,957,0,0, 3,11,0,0,0,0)) |
32328e6c MD |
72 | /** |
73 | * timer_start - called when the timer is started | |
74 | * @timer: pointer to struct timer_list | |
75 | * @expires: the timers expiry time | |
76 | * @flags: the timers expiry time | |
77 | */ | |
78 | LTTNG_TRACEPOINT_EVENT(timer_start, | |
79 | ||
80 | TP_PROTO(struct timer_list *timer, unsigned long expires, | |
81 | unsigned int flags), | |
82 | ||
83 | TP_ARGS(timer, expires, flags), | |
84 | ||
85 | TP_FIELDS( | |
fa91fcac MD |
86 | ctf_integer_hex(void *, timer, timer) |
87 | ctf_integer_hex(void *, function, timer->function) | |
32328e6c MD |
88 | ctf_integer(unsigned long, expires, expires) |
89 | ctf_integer(unsigned long, now, jiffies) | |
90 | ctf_integer(unsigned int, flags, flags) | |
91 | ) | |
92 | ) | |
f4c1678d | 93 | #else |
e54456f5 MD |
94 | /** |
95 | * timer_start - called when the timer is started | |
96 | * @timer: pointer to struct timer_list | |
97 | * @expires: the timers expiry time | |
98 | */ | |
3bc29f0a | 99 | LTTNG_TRACEPOINT_EVENT(timer_start, |
e54456f5 MD |
100 | |
101 | TP_PROTO(struct timer_list *timer, unsigned long expires), | |
102 | ||
103 | TP_ARGS(timer, expires), | |
104 | ||
f127e61e | 105 | TP_FIELDS( |
fa91fcac MD |
106 | ctf_integer_hex(void *, timer, timer) |
107 | ctf_integer_hex(void *, function, timer->function) | |
f127e61e MD |
108 | ctf_integer(unsigned long, expires, expires) |
109 | ctf_integer(unsigned long, now, jiffies) | |
110 | ) | |
e54456f5 | 111 | ) |
f4c1678d | 112 | #endif |
e54456f5 | 113 | |
57acf405 MJ |
114 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \ |
115 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0)) | |
d88e2fe5 MJ |
116 | /** |
117 | * timer_expire_entry - called immediately before the timer callback | |
118 | * @timer: pointer to struct timer_list | |
119 | * | |
120 | * Allows to determine the timer latency. | |
121 | */ | |
122 | LTTNG_TRACEPOINT_EVENT(timer_expire_entry, | |
123 | ||
124 | TP_PROTO(struct timer_list *timer, unsigned long baseclk), | |
125 | ||
126 | TP_ARGS(timer, baseclk), | |
127 | ||
128 | TP_FIELDS( | |
129 | ctf_integer_hex(void *, timer, timer) | |
130 | ctf_integer(unsigned long, now, jiffies) | |
131 | ctf_integer_hex(void *, function, timer->function) | |
132 | ctf_integer(unsigned long, baseclk, baseclk) | |
133 | ) | |
134 | ) | |
135 | #else | |
e54456f5 MD |
136 | /** |
137 | * timer_expire_entry - called immediately before the timer callback | |
138 | * @timer: pointer to struct timer_list | |
139 | * | |
140 | * Allows to determine the timer latency. | |
141 | */ | |
3bc29f0a | 142 | LTTNG_TRACEPOINT_EVENT(timer_expire_entry, |
e54456f5 MD |
143 | |
144 | TP_PROTO(struct timer_list *timer), | |
145 | ||
146 | TP_ARGS(timer), | |
147 | ||
f127e61e | 148 | TP_FIELDS( |
fa91fcac | 149 | ctf_integer_hex(void *, timer, timer) |
f127e61e | 150 | ctf_integer(unsigned long, now, jiffies) |
fa91fcac | 151 | ctf_integer_hex(void *, function, timer->function) |
f127e61e | 152 | ) |
e54456f5 | 153 | ) |
d88e2fe5 | 154 | #endif |
e54456f5 MD |
155 | |
156 | /** | |
157 | * timer_expire_exit - called immediately after the timer callback returns | |
158 | * @timer: pointer to struct timer_list | |
159 | * | |
160 | * When used in combination with the timer_expire_entry tracepoint we can | |
161 | * determine the runtime of the timer callback function. | |
162 | * | |
163 | * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might | |
164 | * be invalid. We solely track the pointer. | |
165 | */ | |
3bc29f0a | 166 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit, |
e54456f5 MD |
167 | |
168 | TP_PROTO(struct timer_list *timer), | |
169 | ||
170 | TP_ARGS(timer) | |
171 | ) | |
172 | ||
173 | /** | |
174 | * timer_cancel - called when the timer is canceled | |
175 | * @timer: pointer to struct timer_list | |
176 | */ | |
3bc29f0a | 177 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel, |
e54456f5 MD |
178 | |
179 | TP_PROTO(struct timer_list *timer), | |
180 | ||
181 | TP_ARGS(timer) | |
182 | ) | |
183 | ||
184 | /** | |
185 | * hrtimer_init - called when the hrtimer is initialized | |
186 | * @timer: pointer to struct hrtimer | |
187 | * @clockid: the hrtimers clock | |
188 | * @mode: the hrtimers mode | |
189 | */ | |
9bbf98da MD |
190 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init, |
191 | ||
192 | timer_hrtimer_init, | |
e54456f5 MD |
193 | |
194 | TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid, | |
195 | enum hrtimer_mode mode), | |
196 | ||
197 | TP_ARGS(hrtimer, clockid, mode), | |
198 | ||
f127e61e | 199 | TP_FIELDS( |
fa91fcac | 200 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e MD |
201 | ctf_integer(clockid_t, clockid, clockid) |
202 | ctf_integer(enum hrtimer_mode, mode, mode) | |
203 | ) | |
e54456f5 MD |
204 | ) |
205 | ||
206 | /** | |
207 | * hrtimer_start - called when the hrtimer is started | |
208 | * @timer: pointer to struct hrtimer | |
209 | */ | |
5f4c791e | 210 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \ |
562860aa RV |
211 | LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0)) |
212 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start, | |
213 | ||
214 | timer_hrtimer_start, | |
215 | ||
216 | TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode), | |
217 | ||
218 | TP_ARGS(hrtimer, mode), | |
219 | ||
220 | TP_FIELDS( | |
221 | ctf_integer_hex(void *, hrtimer, hrtimer) | |
222 | ctf_integer_hex(void *, function, hrtimer->function) | |
223 | ctf_integer(s64, expires, | |
224 | lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer))) | |
225 | ctf_integer(s64, softexpires, | |
226 | lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer))) | |
227 | ctf_integer(enum hrtimer_mode, mode, mode) | |
228 | ) | |
229 | ) | |
230 | #else | |
9bbf98da MD |
231 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start, |
232 | ||
233 | timer_hrtimer_start, | |
e54456f5 MD |
234 | |
235 | TP_PROTO(struct hrtimer *hrtimer), | |
236 | ||
237 | TP_ARGS(hrtimer), | |
238 | ||
f127e61e | 239 | TP_FIELDS( |
fa91fcac MD |
240 | ctf_integer_hex(void *, hrtimer, hrtimer) |
241 | ctf_integer_hex(void *, function, hrtimer->function) | |
507143bc MD |
242 | ctf_integer(s64, expires, |
243 | lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer))) | |
244 | ctf_integer(s64, softexpires, | |
245 | lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer))) | |
f127e61e | 246 | ) |
e54456f5 | 247 | ) |
562860aa | 248 | #endif |
e54456f5 MD |
249 | |
250 | /** | |
251 | * htimmer_expire_entry - called immediately before the hrtimer callback | |
252 | * @timer: pointer to struct hrtimer | |
253 | * @now: pointer to variable which contains current time of the | |
254 | * timers base. | |
255 | * | |
256 | * Allows to determine the timer latency. | |
257 | */ | |
9bbf98da MD |
258 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry, |
259 | ||
260 | timer_hrtimer_expire_entry, | |
e54456f5 MD |
261 | |
262 | TP_PROTO(struct hrtimer *hrtimer, ktime_t *now), | |
263 | ||
264 | TP_ARGS(hrtimer, now), | |
265 | ||
f127e61e | 266 | TP_FIELDS( |
fa91fcac | 267 | ctf_integer_hex(void *, hrtimer, hrtimer) |
507143bc | 268 | ctf_integer(s64, now, lttng_ktime_get_tv64(*now)) |
fa91fcac | 269 | ctf_integer_hex(void *, function, hrtimer->function) |
f127e61e | 270 | ) |
e54456f5 MD |
271 | ) |
272 | ||
9bbf98da | 273 | LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class, |
e54456f5 MD |
274 | |
275 | TP_PROTO(struct hrtimer *hrtimer), | |
276 | ||
277 | TP_ARGS(hrtimer), | |
278 | ||
f127e61e | 279 | TP_FIELDS( |
fa91fcac | 280 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e | 281 | ) |
e54456f5 MD |
282 | ) |
283 | ||
284 | /** | |
285 | * hrtimer_expire_exit - called immediately after the hrtimer callback returns | |
286 | * @timer: pointer to struct hrtimer | |
287 | * | |
288 | * When used in combination with the hrtimer_expire_entry tracepoint we can | |
289 | * determine the runtime of the callback function. | |
290 | */ | |
9bbf98da MD |
291 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit, |
292 | ||
293 | timer_hrtimer_expire_exit, | |
e54456f5 MD |
294 | |
295 | TP_PROTO(struct hrtimer *hrtimer), | |
296 | ||
297 | TP_ARGS(hrtimer) | |
298 | ) | |
299 | ||
300 | /** | |
301 | * hrtimer_cancel - called when the hrtimer is canceled | |
302 | * @hrtimer: pointer to struct hrtimer | |
303 | */ | |
9bbf98da MD |
304 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel, |
305 | ||
306 | timer_hrtimer_cancel, | |
e54456f5 MD |
307 | |
308 | TP_PROTO(struct hrtimer *hrtimer), | |
309 | ||
310 | TP_ARGS(hrtimer) | |
311 | ) | |
312 | ||
313 | /** | |
314 | * itimer_state - called when itimer is started or canceled | |
315 | * @which: name of the interval timer | |
316 | * @value: the itimers value, itimer is canceled if value->it_value is | |
317 | * zero, otherwise it is started | |
318 | * @expires: the itimers expiry time | |
319 | */ | |
5f4c791e | 320 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0)) |
7c1dd120 MJ |
321 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
322 | ||
323 | timer_itimer_state, | |
324 | ||
325 | TP_PROTO(int which, const struct itimerspec64 *const value, | |
326 | unsigned long long expires), | |
327 | ||
328 | TP_ARGS(which, value, expires), | |
329 | ||
330 | TP_FIELDS( | |
331 | ctf_integer(int, which, which) | |
332 | ctf_integer(unsigned long long, expires, expires) | |
333 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
334 | ctf_integer(long, value_nsec, value->it_value.tv_nsec) | |
335 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
336 | ctf_integer(long, interval_nsec, value->it_interval.tv_nsec) | |
337 | ) | |
338 | ) | |
5f4c791e | 339 | #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) |
678dd1c8 FD |
340 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
341 | ||
342 | timer_itimer_state, | |
343 | ||
344 | TP_PROTO(int which, const struct itimerval *const value, | |
345 | unsigned long long expires), | |
346 | ||
347 | TP_ARGS(which, value, expires), | |
348 | ||
349 | TP_FIELDS( | |
350 | ctf_integer(int, which, which) | |
351 | ctf_integer(unsigned long long, expires, expires) | |
352 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
353 | ctf_integer(long, value_usec, value->it_value.tv_usec) | |
354 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
355 | ctf_integer(long, interval_usec, value->it_interval.tv_usec) | |
356 | ) | |
357 | ) | |
5f4c791e | 358 | #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
9bbf98da MD |
359 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
360 | ||
361 | timer_itimer_state, | |
e54456f5 MD |
362 | |
363 | TP_PROTO(int which, const struct itimerval *const value, | |
364 | cputime_t expires), | |
365 | ||
366 | TP_ARGS(which, value, expires), | |
367 | ||
f127e61e MD |
368 | TP_FIELDS( |
369 | ctf_integer(int, which, which) | |
370 | ctf_integer(cputime_t, expires, expires) | |
371 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
372 | ctf_integer(long, value_usec, value->it_value.tv_usec) | |
373 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
374 | ctf_integer(long, interval_usec, value->it_interval.tv_usec) | |
375 | ) | |
e54456f5 | 376 | ) |
5f4c791e | 377 | #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
e54456f5 MD |
378 | |
379 | /** | |
380 | * itimer_expire - called when itimer expires | |
381 | * @which: type of the interval timer | |
382 | * @pid: pid of the process which owns the timer | |
383 | * @now: current time, used to calculate the latency of itimer | |
384 | */ | |
5f4c791e | 385 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) |
678dd1c8 FD |
386 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire, |
387 | ||
388 | timer_itimer_expire, | |
389 | ||
390 | TP_PROTO(int which, struct pid *pid, unsigned long long now), | |
391 | ||
392 | TP_ARGS(which, pid, now), | |
393 | ||
394 | TP_FIELDS( | |
395 | ctf_integer(int , which, which) | |
396 | ctf_integer(pid_t, pid, pid_nr(pid)) | |
397 | ctf_integer(unsigned long long, now, now) | |
398 | ) | |
399 | ) | |
5f4c791e | 400 | #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
9bbf98da MD |
401 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire, |
402 | ||
403 | timer_itimer_expire, | |
e54456f5 MD |
404 | |
405 | TP_PROTO(int which, struct pid *pid, cputime_t now), | |
406 | ||
407 | TP_ARGS(which, pid, now), | |
408 | ||
f127e61e MD |
409 | TP_FIELDS( |
410 | ctf_integer(int , which, which) | |
411 | ctf_integer(pid_t, pid, pid_nr(pid)) | |
412 | ctf_integer(cputime_t, now, now) | |
413 | ) | |
e54456f5 | 414 | ) |
5f4c791e | 415 | #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
e54456f5 | 416 | |
3bc29f0a | 417 | #endif /* LTTNG_TRACE_TIMER_H */ |
e54456f5 MD |
418 | |
419 | /* This part must be outside protection */ | |
3b4aafcb | 420 | #include <lttng/define_trace.h> |