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