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