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