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