1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #define TRACE_SYSTEM timer
5 #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_TIMER_H
8 #include <lttng/tracepoint-event.h>
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>
18 #endif /* _TRACE_TIMER_DEF_ */
20 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
21 #define lttng_ktime_get_tv64(kt) (kt)
22 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
23 #define lttng_ktime_get_tv64(kt) ((kt).tv64)
24 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
26 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
28 TP_PROTO(struct timer_list
*timer
),
33 ctf_integer_hex(void *, timer
, timer
)
38 * timer_init - called when the timer is initialized
39 * @timer: pointer to struct timer_list
41 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
43 TP_PROTO(struct timer_list
*timer
),
48 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
50 * timer_start - called when the timer is started
51 * @timer: pointer to struct timer_list
52 * @expires: the timers expiry time
53 * @flags: the timers expiry time
55 LTTNG_TRACEPOINT_EVENT(timer_start
,
57 TP_PROTO(struct timer_list
*timer
, unsigned long bucket_expiry
),
59 TP_ARGS(timer
, bucket_expiry
),
62 ctf_integer_hex(void *, timer
, timer
)
63 ctf_integer_hex(void *, function
, timer
->function
)
64 ctf_integer(unsigned long, expires
, timer
->expires
)
65 ctf_integer(unsigned long, bucket_expiry
, bucket_expiry
)
66 ctf_integer(unsigned long, now
, jiffies
)
67 ctf_integer(unsigned int, flags
, timer
->flags
)
70 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0) || \
71 LTTNG_RHEL_KERNEL_RANGE(3,10,0,957,0,0, 3,11,0,0,0,0))
73 * timer_start - called when the timer is started
74 * @timer: pointer to struct timer_list
75 * @expires: the timers expiry time
76 * @flags: the timers expiry time
78 LTTNG_TRACEPOINT_EVENT(timer_start
,
80 TP_PROTO(struct timer_list
*timer
, unsigned long expires
,
83 TP_ARGS(timer
, expires
, flags
),
86 ctf_integer_hex(void *, timer
, timer
)
87 ctf_integer_hex(void *, function
, timer
->function
)
88 ctf_integer(unsigned long, expires
, expires
)
89 ctf_integer(unsigned long, now
, jiffies
)
90 ctf_integer(unsigned int, flags
, flags
)
95 * timer_start - called when the timer is started
96 * @timer: pointer to struct timer_list
97 * @expires: the timers expiry time
99 LTTNG_TRACEPOINT_EVENT(timer_start
,
101 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
103 TP_ARGS(timer
, expires
),
106 ctf_integer_hex(void *, timer
, timer
)
107 ctf_integer_hex(void *, function
, timer
->function
)
108 ctf_integer(unsigned long, expires
, expires
)
109 ctf_integer(unsigned long, now
, jiffies
)
114 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \
115 LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0))
117 * timer_expire_entry - called immediately before the timer callback
118 * @timer: pointer to struct timer_list
120 * Allows to determine the timer latency.
122 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
124 TP_PROTO(struct timer_list
*timer
, unsigned long baseclk
),
126 TP_ARGS(timer
, baseclk
),
129 ctf_integer_hex(void *, timer
, timer
)
130 ctf_integer(unsigned long, now
, jiffies
)
131 ctf_integer_hex(void *, function
, timer
->function
)
132 ctf_integer(unsigned long, baseclk
, baseclk
)
137 * timer_expire_entry - called immediately before the timer callback
138 * @timer: pointer to struct timer_list
140 * Allows to determine the timer latency.
142 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
144 TP_PROTO(struct timer_list
*timer
),
149 ctf_integer_hex(void *, timer
, timer
)
150 ctf_integer(unsigned long, now
, jiffies
)
151 ctf_integer_hex(void *, function
, timer
->function
)
157 * timer_expire_exit - called immediately after the timer callback returns
158 * @timer: pointer to struct timer_list
160 * When used in combination with the timer_expire_entry tracepoint we can
161 * determine the runtime of the timer callback function.
163 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
164 * be invalid. We solely track the pointer.
166 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_expire_exit
,
168 TP_PROTO(struct timer_list
*timer
),
174 * timer_cancel - called when the timer is canceled
175 * @timer: pointer to struct timer_list
177 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_cancel
,
179 TP_PROTO(struct timer_list
*timer
),
185 * hrtimer_init - called when the hrtimer is initialized
186 * @timer: pointer to struct hrtimer
187 * @clockid: the hrtimers clock
188 * @mode: the hrtimers mode
190 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init
,
194 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
195 enum hrtimer_mode mode
),
197 TP_ARGS(hrtimer
, clockid
, mode
),
200 ctf_integer_hex(void *, hrtimer
, hrtimer
)
201 ctf_integer(clockid_t
, clockid
, clockid
)
202 ctf_integer(enum hrtimer_mode
, mode
, mode
)
207 * hrtimer_start - called when the hrtimer is started
208 * @timer: pointer to struct hrtimer
210 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \
211 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
212 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
216 TP_PROTO(struct hrtimer
*hrtimer
, enum hrtimer_mode mode
),
218 TP_ARGS(hrtimer
, mode
),
221 ctf_integer_hex(void *, hrtimer
, hrtimer
)
222 ctf_integer_hex(void *, function
, hrtimer
->function
)
223 ctf_integer(s64
, expires
,
224 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer
)))
225 ctf_integer(s64
, softexpires
,
226 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer
)))
227 ctf_integer(enum hrtimer_mode
, mode
, mode
)
231 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
235 TP_PROTO(struct hrtimer
*hrtimer
),
240 ctf_integer_hex(void *, hrtimer
, hrtimer
)
241 ctf_integer_hex(void *, function
, hrtimer
->function
)
242 ctf_integer(s64
, expires
,
243 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer
)))
244 ctf_integer(s64
, softexpires
,
245 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer
)))
251 * htimmer_expire_entry - called immediately before the hrtimer callback
252 * @timer: pointer to struct hrtimer
253 * @now: pointer to variable which contains current time of the
256 * Allows to determine the timer latency.
258 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry
,
260 timer_hrtimer_expire_entry
,
262 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
264 TP_ARGS(hrtimer
, now
),
267 ctf_integer_hex(void *, hrtimer
, hrtimer
)
268 ctf_integer(s64
, now
, lttng_ktime_get_tv64(*now
))
269 ctf_integer_hex(void *, function
, hrtimer
->function
)
273 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class
,
275 TP_PROTO(struct hrtimer
*hrtimer
),
280 ctf_integer_hex(void *, hrtimer
, hrtimer
)
285 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
286 * @timer: pointer to struct hrtimer
288 * When used in combination with the hrtimer_expire_entry tracepoint we can
289 * determine the runtime of the callback function.
291 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_expire_exit
,
293 timer_hrtimer_expire_exit
,
295 TP_PROTO(struct hrtimer
*hrtimer
),
301 * hrtimer_cancel - called when the hrtimer is canceled
302 * @hrtimer: pointer to struct hrtimer
304 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_cancel
,
306 timer_hrtimer_cancel
,
308 TP_PROTO(struct hrtimer
*hrtimer
),
314 * itimer_state - called when itimer is started or canceled
315 * @which: name of the interval timer
316 * @value: the itimers value, itimer is canceled if value->it_value is
317 * zero, otherwise it is started
318 * @expires: the itimers expiry time
320 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
321 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
325 TP_PROTO(int which
, const struct itimerspec64
*const value
,
326 unsigned long long expires
),
328 TP_ARGS(which
, value
, expires
),
331 ctf_integer(int, which
, which
)
332 ctf_integer(unsigned long long, expires
, expires
)
333 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
334 ctf_integer(long, value_nsec
, value
->it_value
.tv_nsec
)
335 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
336 ctf_integer(long, interval_nsec
, value
->it_interval
.tv_nsec
)
339 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
340 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
344 TP_PROTO(int which
, const struct itimerval
*const value
,
345 unsigned long long expires
),
347 TP_ARGS(which
, value
, expires
),
350 ctf_integer(int, which
, which
)
351 ctf_integer(unsigned long long, expires
, expires
)
352 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
353 ctf_integer(long, value_usec
, value
->it_value
.tv_usec
)
354 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
355 ctf_integer(long, interval_usec
, value
->it_interval
.tv_usec
)
358 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
359 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
363 TP_PROTO(int which
, const struct itimerval
*const value
,
366 TP_ARGS(which
, value
, expires
),
369 ctf_integer(int, which
, which
)
370 ctf_integer(cputime_t
, expires
, expires
)
371 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
372 ctf_integer(long, value_usec
, value
->it_value
.tv_usec
)
373 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
374 ctf_integer(long, interval_usec
, value
->it_interval
.tv_usec
)
377 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
380 * itimer_expire - called when itimer expires
381 * @which: type of the interval timer
382 * @pid: pid of the process which owns the timer
383 * @now: current time, used to calculate the latency of itimer
385 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
386 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
390 TP_PROTO(int which
, struct pid
*pid
, unsigned long long now
),
392 TP_ARGS(which
, pid
, now
),
395 ctf_integer(int , which
, which
)
396 ctf_integer(pid_t
, pid
, pid_nr(pid
))
397 ctf_integer(unsigned long long, now
, now
)
400 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
401 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
405 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
407 TP_ARGS(which
, pid
, now
),
410 ctf_integer(int , which
, which
)
411 ctf_integer(pid_t
, pid
, pid_nr(pid
))
412 ctf_integer(cputime_t
, now
, now
)
415 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
417 #endif /* LTTNG_TRACE_TIMER_H */
419 /* This part must be outside protection */
420 #include <lttng/define_trace.h>