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