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 | 126 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \ |
fb4b9097 | 127 | LTTNG_KERNEL_RANGE(4,19,312, 4,20,0) || \ |
05355f0b | 128 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0)) |
d88e2fe5 MJ |
129 | /** |
130 | * timer_expire_entry - called immediately before the timer callback | |
131 | * @timer: pointer to struct timer_list | |
132 | * | |
133 | * Allows to determine the timer latency. | |
134 | */ | |
135 | LTTNG_TRACEPOINT_EVENT(timer_expire_entry, | |
136 | ||
137 | TP_PROTO(struct timer_list *timer, unsigned long baseclk), | |
138 | ||
139 | TP_ARGS(timer, baseclk), | |
140 | ||
141 | TP_FIELDS( | |
142 | ctf_integer_hex(void *, timer, timer) | |
143 | ctf_integer(unsigned long, now, jiffies) | |
144 | ctf_integer_hex(void *, function, timer->function) | |
145 | ctf_integer(unsigned long, baseclk, baseclk) | |
146 | ) | |
147 | ) | |
148 | #else | |
e54456f5 MD |
149 | /** |
150 | * timer_expire_entry - called immediately before the timer callback | |
151 | * @timer: pointer to struct timer_list | |
152 | * | |
153 | * Allows to determine the timer latency. | |
154 | */ | |
3bc29f0a | 155 | LTTNG_TRACEPOINT_EVENT(timer_expire_entry, |
e54456f5 MD |
156 | |
157 | TP_PROTO(struct timer_list *timer), | |
158 | ||
159 | TP_ARGS(timer), | |
160 | ||
f127e61e | 161 | TP_FIELDS( |
fa91fcac | 162 | ctf_integer_hex(void *, timer, timer) |
f127e61e | 163 | ctf_integer(unsigned long, now, jiffies) |
fa91fcac | 164 | ctf_integer_hex(void *, function, timer->function) |
f127e61e | 165 | ) |
e54456f5 | 166 | ) |
d88e2fe5 | 167 | #endif |
e54456f5 MD |
168 | |
169 | /** | |
170 | * timer_expire_exit - called immediately after the timer callback returns | |
171 | * @timer: pointer to struct timer_list | |
172 | * | |
173 | * When used in combination with the timer_expire_entry tracepoint we can | |
174 | * determine the runtime of the timer callback function. | |
175 | * | |
176 | * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might | |
177 | * be invalid. We solely track the pointer. | |
178 | */ | |
3bc29f0a | 179 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit, |
e54456f5 MD |
180 | |
181 | TP_PROTO(struct timer_list *timer), | |
182 | ||
183 | TP_ARGS(timer) | |
184 | ) | |
185 | ||
186 | /** | |
187 | * timer_cancel - called when the timer is canceled | |
188 | * @timer: pointer to struct timer_list | |
189 | */ | |
3bc29f0a | 190 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel, |
e54456f5 MD |
191 | |
192 | TP_PROTO(struct timer_list *timer), | |
193 | ||
194 | TP_ARGS(timer) | |
195 | ) | |
196 | ||
197 | /** | |
198 | * hrtimer_init - called when the hrtimer is initialized | |
199 | * @timer: pointer to struct hrtimer | |
200 | * @clockid: the hrtimers clock | |
201 | * @mode: the hrtimers mode | |
202 | */ | |
9bbf98da MD |
203 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init, |
204 | ||
205 | timer_hrtimer_init, | |
e54456f5 MD |
206 | |
207 | TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid, | |
208 | enum hrtimer_mode mode), | |
209 | ||
210 | TP_ARGS(hrtimer, clockid, mode), | |
211 | ||
f127e61e | 212 | TP_FIELDS( |
fa91fcac | 213 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e | 214 | ctf_integer(clockid_t, clockid, clockid) |
9f5c9fe5 | 215 | ctf_enum(hrtimer_mode, unsigned int, mode, mode) |
f127e61e | 216 | ) |
e54456f5 MD |
217 | ) |
218 | ||
219 | /** | |
220 | * hrtimer_start - called when the hrtimer is started | |
221 | * @timer: pointer to struct hrtimer | |
222 | */ | |
5f4c791e | 223 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \ |
562860aa RV |
224 | LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0)) |
225 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start, | |
226 | ||
227 | timer_hrtimer_start, | |
228 | ||
229 | TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode), | |
230 | ||
231 | TP_ARGS(hrtimer, mode), | |
232 | ||
233 | TP_FIELDS( | |
234 | ctf_integer_hex(void *, hrtimer, hrtimer) | |
235 | ctf_integer_hex(void *, function, hrtimer->function) | |
236 | ctf_integer(s64, expires, | |
237 | lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer))) | |
238 | ctf_integer(s64, softexpires, | |
239 | lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer))) | |
9f5c9fe5 | 240 | ctf_enum(hrtimer_mode, unsigned int, mode, mode) |
562860aa RV |
241 | ) |
242 | ) | |
243 | #else | |
9bbf98da MD |
244 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start, |
245 | ||
246 | timer_hrtimer_start, | |
e54456f5 MD |
247 | |
248 | TP_PROTO(struct hrtimer *hrtimer), | |
249 | ||
250 | TP_ARGS(hrtimer), | |
251 | ||
f127e61e | 252 | TP_FIELDS( |
fa91fcac MD |
253 | ctf_integer_hex(void *, hrtimer, hrtimer) |
254 | ctf_integer_hex(void *, function, hrtimer->function) | |
507143bc MD |
255 | ctf_integer(s64, expires, |
256 | lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer))) | |
257 | ctf_integer(s64, softexpires, | |
258 | lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer))) | |
f127e61e | 259 | ) |
e54456f5 | 260 | ) |
562860aa | 261 | #endif |
e54456f5 MD |
262 | |
263 | /** | |
264 | * htimmer_expire_entry - called immediately before the hrtimer callback | |
265 | * @timer: pointer to struct hrtimer | |
266 | * @now: pointer to variable which contains current time of the | |
267 | * timers base. | |
268 | * | |
269 | * Allows to determine the timer latency. | |
270 | */ | |
9bbf98da MD |
271 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry, |
272 | ||
273 | timer_hrtimer_expire_entry, | |
e54456f5 MD |
274 | |
275 | TP_PROTO(struct hrtimer *hrtimer, ktime_t *now), | |
276 | ||
277 | TP_ARGS(hrtimer, now), | |
278 | ||
f127e61e | 279 | TP_FIELDS( |
fa91fcac | 280 | ctf_integer_hex(void *, hrtimer, hrtimer) |
507143bc | 281 | ctf_integer(s64, now, lttng_ktime_get_tv64(*now)) |
fa91fcac | 282 | ctf_integer_hex(void *, function, hrtimer->function) |
f127e61e | 283 | ) |
e54456f5 MD |
284 | ) |
285 | ||
9bbf98da | 286 | LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class, |
e54456f5 MD |
287 | |
288 | TP_PROTO(struct hrtimer *hrtimer), | |
289 | ||
290 | TP_ARGS(hrtimer), | |
291 | ||
f127e61e | 292 | TP_FIELDS( |
fa91fcac | 293 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e | 294 | ) |
e54456f5 MD |
295 | ) |
296 | ||
297 | /** | |
298 | * hrtimer_expire_exit - called immediately after the hrtimer callback returns | |
299 | * @timer: pointer to struct hrtimer | |
300 | * | |
301 | * When used in combination with the hrtimer_expire_entry tracepoint we can | |
302 | * determine the runtime of the callback function. | |
303 | */ | |
9bbf98da MD |
304 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit, |
305 | ||
306 | timer_hrtimer_expire_exit, | |
e54456f5 MD |
307 | |
308 | TP_PROTO(struct hrtimer *hrtimer), | |
309 | ||
310 | TP_ARGS(hrtimer) | |
311 | ) | |
312 | ||
313 | /** | |
314 | * hrtimer_cancel - called when the hrtimer is canceled | |
315 | * @hrtimer: pointer to struct hrtimer | |
316 | */ | |
9bbf98da MD |
317 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel, |
318 | ||
319 | timer_hrtimer_cancel, | |
e54456f5 MD |
320 | |
321 | TP_PROTO(struct hrtimer *hrtimer), | |
322 | ||
323 | TP_ARGS(hrtimer) | |
324 | ) | |
325 | ||
326 | /** | |
327 | * itimer_state - called when itimer is started or canceled | |
328 | * @which: name of the interval timer | |
329 | * @value: the itimers value, itimer is canceled if value->it_value is | |
330 | * zero, otherwise it is started | |
331 | * @expires: the itimers expiry time | |
332 | */ | |
5f4c791e | 333 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0)) |
7c1dd120 MJ |
334 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
335 | ||
336 | timer_itimer_state, | |
337 | ||
338 | TP_PROTO(int which, const struct itimerspec64 *const value, | |
339 | unsigned long long expires), | |
340 | ||
341 | TP_ARGS(which, value, expires), | |
342 | ||
343 | TP_FIELDS( | |
344 | ctf_integer(int, which, which) | |
345 | ctf_integer(unsigned long long, expires, expires) | |
346 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
347 | ctf_integer(long, value_nsec, value->it_value.tv_nsec) | |
348 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
349 | ctf_integer(long, interval_nsec, value->it_interval.tv_nsec) | |
350 | ) | |
351 | ) | |
5f4c791e | 352 | #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) |
678dd1c8 FD |
353 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
354 | ||
355 | timer_itimer_state, | |
356 | ||
357 | TP_PROTO(int which, const struct itimerval *const value, | |
358 | unsigned long long expires), | |
359 | ||
360 | TP_ARGS(which, value, expires), | |
361 | ||
362 | TP_FIELDS( | |
363 | ctf_integer(int, which, which) | |
364 | ctf_integer(unsigned long long, expires, expires) | |
365 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
366 | ctf_integer(long, value_usec, value->it_value.tv_usec) | |
367 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
368 | ctf_integer(long, interval_usec, value->it_interval.tv_usec) | |
369 | ) | |
370 | ) | |
5f4c791e | 371 | #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
9bbf98da MD |
372 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
373 | ||
374 | timer_itimer_state, | |
e54456f5 MD |
375 | |
376 | TP_PROTO(int which, const struct itimerval *const value, | |
377 | cputime_t expires), | |
378 | ||
379 | TP_ARGS(which, value, expires), | |
380 | ||
f127e61e MD |
381 | TP_FIELDS( |
382 | ctf_integer(int, which, which) | |
383 | ctf_integer(cputime_t, expires, expires) | |
384 | ctf_integer(long, value_sec, value->it_value.tv_sec) | |
385 | ctf_integer(long, value_usec, value->it_value.tv_usec) | |
386 | ctf_integer(long, interval_sec, value->it_interval.tv_sec) | |
387 | ctf_integer(long, interval_usec, value->it_interval.tv_usec) | |
388 | ) | |
e54456f5 | 389 | ) |
5f4c791e | 390 | #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
e54456f5 MD |
391 | |
392 | /** | |
393 | * itimer_expire - called when itimer expires | |
394 | * @which: type of the interval timer | |
395 | * @pid: pid of the process which owns the timer | |
396 | * @now: current time, used to calculate the latency of itimer | |
397 | */ | |
5f4c791e | 398 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) |
678dd1c8 FD |
399 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire, |
400 | ||
401 | timer_itimer_expire, | |
402 | ||
403 | TP_PROTO(int which, struct pid *pid, unsigned long long now), | |
404 | ||
405 | TP_ARGS(which, pid, now), | |
406 | ||
407 | TP_FIELDS( | |
408 | ctf_integer(int , which, which) | |
409 | ctf_integer(pid_t, pid, pid_nr(pid)) | |
410 | ctf_integer(unsigned long long, now, now) | |
411 | ) | |
412 | ) | |
5f4c791e | 413 | #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
9bbf98da MD |
414 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire, |
415 | ||
416 | timer_itimer_expire, | |
e54456f5 MD |
417 | |
418 | TP_PROTO(int which, struct pid *pid, cputime_t now), | |
419 | ||
420 | TP_ARGS(which, pid, now), | |
421 | ||
f127e61e MD |
422 | TP_FIELDS( |
423 | ctf_integer(int , which, which) | |
424 | ctf_integer(pid_t, pid, pid_nr(pid)) | |
425 | ctf_integer(cputime_t, now, now) | |
426 | ) | |
e54456f5 | 427 | ) |
5f4c791e | 428 | #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */ |
e54456f5 | 429 | |
3bc29f0a | 430 | #endif /* LTTNG_TRACE_TIMER_H */ |
e54456f5 MD |
431 | |
432 | /* This part must be outside protection */ | |
3b4aafcb | 433 | #include <lttng/define_trace.h> |