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