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