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