193650bb3780d5755fd7d8878afba027ec9ef81a
[lttng-modules.git] / include / instrumentation / events / timer.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM timer
4
5 #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_TIMER_H
7
8 #include <lttng/tracepoint-event.h>
9
10 #ifndef _TRACE_TIMER_DEF_
11 #define _TRACE_TIMER_DEF_
12 #include <linux/hrtimer.h>
13 #include <linux/timer.h>
14 #include <lttng/kernel-version.h>
15
16 struct timer_list;
17
18 #endif /* _TRACE_TIMER_DEF_ */
19
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
52 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
53 #define lttng_ktime_get_tv64(kt) (kt)
54 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
55 #define lttng_ktime_get_tv64(kt) ((kt).tv64)
56 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
57
58 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
59
60 TP_PROTO(struct timer_list *timer),
61
62 TP_ARGS(timer),
63
64 TP_FIELDS(
65 ctf_integer_hex(void *, timer, timer)
66 )
67 )
68
69 /**
70 * timer_init - called when the timer is initialized
71 * @timer: pointer to struct timer_list
72 */
73 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
74
75 TP_PROTO(struct timer_list *timer),
76
77 TP_ARGS(timer)
78 )
79
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
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(
117 ctf_integer_hex(void *, timer, timer)
118 ctf_integer_hex(void *, function, timer->function)
119 ctf_integer(unsigned long, expires, expires)
120 ctf_integer(unsigned long, now, jiffies)
121 ctf_integer(unsigned int, flags, flags)
122 )
123 )
124 #endif
125
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))
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
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 */
154 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
155
156 TP_PROTO(struct timer_list *timer),
157
158 TP_ARGS(timer),
159
160 TP_FIELDS(
161 ctf_integer_hex(void *, timer, timer)
162 ctf_integer(unsigned long, now, jiffies)
163 ctf_integer_hex(void *, function, timer->function)
164 )
165 )
166 #endif
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 */
178 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
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 */
189 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
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 */
202 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
203
204 timer_hrtimer_init,
205
206 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
207 enum hrtimer_mode mode),
208
209 TP_ARGS(hrtimer, clockid, mode),
210
211 TP_FIELDS(
212 ctf_integer_hex(void *, hrtimer, hrtimer)
213 ctf_integer(clockid_t, clockid, clockid)
214 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
215 )
216 )
217
218 /**
219 * hrtimer_start - called when the hrtimer is started
220 * @timer: pointer to struct hrtimer
221 */
222 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \
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)))
239 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
240 )
241 )
242 #else
243 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
244
245 timer_hrtimer_start,
246
247 TP_PROTO(struct hrtimer *hrtimer),
248
249 TP_ARGS(hrtimer),
250
251 TP_FIELDS(
252 ctf_integer_hex(void *, hrtimer, hrtimer)
253 ctf_integer_hex(void *, function, hrtimer->function)
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)))
258 )
259 )
260 #endif
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 */
270 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
271
272 timer_hrtimer_expire_entry,
273
274 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
275
276 TP_ARGS(hrtimer, now),
277
278 TP_FIELDS(
279 ctf_integer_hex(void *, hrtimer, hrtimer)
280 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
281 ctf_integer_hex(void *, function, hrtimer->function)
282 )
283 )
284
285 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
286
287 TP_PROTO(struct hrtimer *hrtimer),
288
289 TP_ARGS(hrtimer),
290
291 TP_FIELDS(
292 ctf_integer_hex(void *, hrtimer, hrtimer)
293 )
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 */
303 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
304
305 timer_hrtimer_expire_exit,
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 */
316 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
317
318 timer_hrtimer_cancel,
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 */
332 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
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 )
351 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
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 )
370 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
371 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
372
373 timer_itimer_state,
374
375 TP_PROTO(int which, const struct itimerval *const value,
376 cputime_t expires),
377
378 TP_ARGS(which, value, expires),
379
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 )
388 )
389 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
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 */
397 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
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 )
412 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
413 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
414
415 timer_itimer_expire,
416
417 TP_PROTO(int which, struct pid *pid, cputime_t now),
418
419 TP_ARGS(which, pid, now),
420
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 )
426 )
427 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
428
429 #endif /* LTTNG_TRACE_TIMER_H */
430
431 /* This part must be outside protection */
432 #include <lttng/define_trace.h>
This page took 0.037863 seconds and 3 git commands to generate.