kvm instrumentation: Fix kvm_mmio event NULL pointer dereference
[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
f97f9d2e
KS
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))
64d3007b
KS
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 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
32328e6c
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 * @flags: the timers expiry time
109 */
110LTTNG_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(
fa91fcac
MD
118 ctf_integer_hex(void *, timer, timer)
119 ctf_integer_hex(void *, function, timer->function)
32328e6c
MD
120 ctf_integer(unsigned long, expires, expires)
121 ctf_integer(unsigned long, now, jiffies)
122 ctf_integer(unsigned int, flags, flags)
123 )
124)
64d3007b 125#endif
e54456f5 126
05355f0b 127#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \
fb4b9097 128 LTTNG_KERNEL_RANGE(4,19,312, 4,20,0) || \
05355f0b 129 LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0))
d88e2fe5
MJ
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 */
136LTTNG_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
e54456f5
MD
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 */
3bc29f0a 156LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
e54456f5
MD
157
158 TP_PROTO(struct timer_list *timer),
159
160 TP_ARGS(timer),
161
f127e61e 162 TP_FIELDS(
fa91fcac 163 ctf_integer_hex(void *, timer, timer)
f127e61e 164 ctf_integer(unsigned long, now, jiffies)
fa91fcac 165 ctf_integer_hex(void *, function, timer->function)
f127e61e 166 )
e54456f5 167)
d88e2fe5 168#endif
e54456f5
MD
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 */
3bc29f0a 180LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
e54456f5
MD
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 */
3bc29f0a 191LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
e54456f5
MD
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 */
9bbf98da
MD
204LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
205
206 timer_hrtimer_init,
e54456f5
MD
207
208 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
209 enum hrtimer_mode mode),
210
211 TP_ARGS(hrtimer, clockid, mode),
212
f127e61e 213 TP_FIELDS(
fa91fcac 214 ctf_integer_hex(void *, hrtimer, hrtimer)
f127e61e 215 ctf_integer(clockid_t, clockid, clockid)
9f5c9fe5 216 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
f127e61e 217 )
e54456f5
MD
218)
219
220/**
221 * hrtimer_start - called when the hrtimer is started
222 * @timer: pointer to struct hrtimer
223 */
5f4c791e 224#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \
562860aa
RV
225 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
226LTTNG_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)))
9f5c9fe5 241 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
562860aa
RV
242 )
243)
244#else
9bbf98da
MD
245LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
246
247 timer_hrtimer_start,
e54456f5
MD
248
249 TP_PROTO(struct hrtimer *hrtimer),
250
251 TP_ARGS(hrtimer),
252
f127e61e 253 TP_FIELDS(
fa91fcac
MD
254 ctf_integer_hex(void *, hrtimer, hrtimer)
255 ctf_integer_hex(void *, function, hrtimer->function)
507143bc
MD
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)))
f127e61e 260 )
e54456f5 261)
562860aa 262#endif
e54456f5
MD
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 */
9bbf98da
MD
272LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
273
274 timer_hrtimer_expire_entry,
e54456f5
MD
275
276 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
277
278 TP_ARGS(hrtimer, now),
279
f127e61e 280 TP_FIELDS(
fa91fcac 281 ctf_integer_hex(void *, hrtimer, hrtimer)
507143bc 282 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
fa91fcac 283 ctf_integer_hex(void *, function, hrtimer->function)
f127e61e 284 )
e54456f5
MD
285)
286
9bbf98da 287LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
e54456f5
MD
288
289 TP_PROTO(struct hrtimer *hrtimer),
290
291 TP_ARGS(hrtimer),
292
f127e61e 293 TP_FIELDS(
fa91fcac 294 ctf_integer_hex(void *, hrtimer, hrtimer)
f127e61e 295 )
e54456f5
MD
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 */
9bbf98da
MD
305LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
306
307 timer_hrtimer_expire_exit,
e54456f5
MD
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 */
9bbf98da
MD
318LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
319
320 timer_hrtimer_cancel,
e54456f5
MD
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 */
5f4c791e 334#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
7c1dd120
MJ
335LTTNG_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)
5f4c791e 353#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
678dd1c8
FD
354LTTNG_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)
5f4c791e 372#else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
9bbf98da
MD
373LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
374
375 timer_itimer_state,
e54456f5
MD
376
377 TP_PROTO(int which, const struct itimerval *const value,
378 cputime_t expires),
379
380 TP_ARGS(which, value, expires),
381
f127e61e
MD
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 )
e54456f5 390)
5f4c791e 391#endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
e54456f5
MD
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 */
5f4c791e 399#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
678dd1c8
FD
400LTTNG_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)
5f4c791e 414#else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
9bbf98da
MD
415LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
416
417 timer_itimer_expire,
e54456f5
MD
418
419 TP_PROTO(int which, struct pid *pid, cputime_t now),
420
421 TP_ARGS(which, pid, now),
422
f127e61e
MD
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 )
e54456f5 428)
5f4c791e 429#endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
e54456f5 430
3bc29f0a 431#endif /* LTTNG_TRACE_TIMER_H */
e54456f5
MD
432
433/* This part must be outside protection */
3b4aafcb 434#include <lttng/define_trace.h>
This page took 0.07772 seconds and 4 git commands to generate.