2 #define TRACE_SYSTEM timer
4 #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_TIMER_H
7 #include <probes/lttng-tracepoint-event.h>
9 #ifndef _TRACE_TIMER_DEF_
10 #define _TRACE_TIMER_DEF_
11 #include <linux/hrtimer.h>
12 #include <linux/timer.h>
13 #include <linux/version.h>
17 #endif /* _TRACE_TIMER_DEF_ */
19 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
20 #define lttng_ktime_get_tv64(kt) (kt)
21 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) */
22 #define lttng_ktime_get_tv64(kt) ((kt).tv64)
23 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) */
25 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
27 TP_PROTO(struct timer_list
*timer
),
32 ctf_integer_hex(void *, timer
, timer
)
37 * timer_init - called when the timer is initialized
38 * @timer: pointer to struct timer_list
40 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
42 TP_PROTO(struct timer_list
*timer
),
47 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0) || \
48 LTTNG_RHEL_KERNEL_RANGE(3,10,0,957,0,0, 3,11,0,0,0,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 expires
,
60 TP_ARGS(timer
, expires
, flags
),
63 ctf_integer_hex(void *, timer
, timer
)
64 ctf_integer_hex(void *, function
, timer
->function
)
65 ctf_integer(unsigned long, expires
, expires
)
66 ctf_integer(unsigned long, now
, jiffies
)
67 ctf_integer(unsigned int, flags
, flags
)
70 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
72 * timer_start - called when the timer is started
73 * @timer: pointer to struct timer_list
74 * @expires: the timers expiry time
76 LTTNG_TRACEPOINT_EVENT(timer_start
,
78 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
80 TP_ARGS(timer
, expires
),
83 ctf_integer_hex(void *, timer
, timer
)
84 ctf_integer_hex(void *, function
, timer
->function
)
85 ctf_integer(unsigned long, expires
, expires
)
86 ctf_integer(unsigned long, now
, jiffies
)
89 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
91 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,2,0))
93 * timer_expire_entry - called immediately before the timer callback
94 * @timer: pointer to struct timer_list
96 * Allows to determine the timer latency.
98 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
100 TP_PROTO(struct timer_list
*timer
, unsigned long baseclk
),
102 TP_ARGS(timer
, baseclk
),
105 ctf_integer_hex(void *, timer
, timer
)
106 ctf_integer(unsigned long, now
, jiffies
)
107 ctf_integer_hex(void *, function
, timer
->function
)
108 ctf_integer(unsigned long, baseclk
, baseclk
)
113 * timer_expire_entry - called immediately before the timer callback
114 * @timer: pointer to struct timer_list
116 * Allows to determine the timer latency.
118 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
120 TP_PROTO(struct timer_list
*timer
),
125 ctf_integer_hex(void *, timer
, timer
)
126 ctf_integer(unsigned long, now
, jiffies
)
127 ctf_integer_hex(void *, function
, timer
->function
)
133 * timer_expire_exit - called immediately after the timer callback returns
134 * @timer: pointer to struct timer_list
136 * When used in combination with the timer_expire_entry tracepoint we can
137 * determine the runtime of the timer callback function.
139 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
140 * be invalid. We solely track the pointer.
142 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_expire_exit
,
144 TP_PROTO(struct timer_list
*timer
),
150 * timer_cancel - called when the timer is canceled
151 * @timer: pointer to struct timer_list
153 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_cancel
,
155 TP_PROTO(struct timer_list
*timer
),
161 * hrtimer_init - called when the hrtimer is initialized
162 * @timer: pointer to struct hrtimer
163 * @clockid: the hrtimers clock
164 * @mode: the hrtimers mode
166 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init
,
170 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
171 enum hrtimer_mode mode
),
173 TP_ARGS(hrtimer
, clockid
, mode
),
176 ctf_integer_hex(void *, hrtimer
, hrtimer
)
177 ctf_integer(clockid_t
, clockid
, clockid
)
178 ctf_integer(enum hrtimer_mode
, mode
, mode
)
183 * hrtimer_start - called when the hrtimer is started
184 * @timer: pointer to struct hrtimer
186 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,16,0) || \
187 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
188 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
192 TP_PROTO(struct hrtimer
*hrtimer
, enum hrtimer_mode mode
),
194 TP_ARGS(hrtimer
, mode
),
197 ctf_integer_hex(void *, hrtimer
, hrtimer
)
198 ctf_integer_hex(void *, function
, hrtimer
->function
)
199 ctf_integer(s64
, expires
,
200 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer
)))
201 ctf_integer(s64
, softexpires
,
202 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer
)))
203 ctf_integer(enum hrtimer_mode
, mode
, mode
)
207 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
211 TP_PROTO(struct hrtimer
*hrtimer
),
216 ctf_integer_hex(void *, hrtimer
, hrtimer
)
217 ctf_integer_hex(void *, function
, hrtimer
->function
)
218 ctf_integer(s64
, expires
,
219 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer
)))
220 ctf_integer(s64
, softexpires
,
221 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer
)))
227 * htimmer_expire_entry - called immediately before the hrtimer callback
228 * @timer: pointer to struct hrtimer
229 * @now: pointer to variable which contains current time of the
232 * Allows to determine the timer latency.
234 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry
,
236 timer_hrtimer_expire_entry
,
238 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
240 TP_ARGS(hrtimer
, now
),
243 ctf_integer_hex(void *, hrtimer
, hrtimer
)
244 ctf_integer(s64
, now
, lttng_ktime_get_tv64(*now
))
245 ctf_integer_hex(void *, function
, hrtimer
->function
)
249 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class
,
251 TP_PROTO(struct hrtimer
*hrtimer
),
256 ctf_integer_hex(void *, hrtimer
, hrtimer
)
261 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
262 * @timer: pointer to struct hrtimer
264 * When used in combination with the hrtimer_expire_entry tracepoint we can
265 * determine the runtime of the callback function.
267 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_expire_exit
,
269 timer_hrtimer_expire_exit
,
271 TP_PROTO(struct hrtimer
*hrtimer
),
277 * hrtimer_cancel - called when the hrtimer is canceled
278 * @hrtimer: pointer to struct hrtimer
280 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_cancel
,
282 timer_hrtimer_cancel
,
284 TP_PROTO(struct hrtimer
*hrtimer
),
290 * itimer_state - called when itimer is started or canceled
291 * @which: name of the interval timer
292 * @value: the itimers value, itimer is canceled if value->it_value is
293 * zero, otherwise it is started
294 * @expires: the itimers expiry time
296 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0))
297 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
301 TP_PROTO(int which
, const struct itimerspec64
*const value
,
302 unsigned long long expires
),
304 TP_ARGS(which
, value
, expires
),
307 ctf_integer(int, which
, which
)
308 ctf_integer(unsigned long long, expires
, expires
)
309 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
310 ctf_integer(long, value_nsec
, value
->it_value
.tv_nsec
)
311 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
312 ctf_integer(long, interval_nsec
, value
->it_interval
.tv_nsec
)
315 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
316 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
320 TP_PROTO(int which
, const struct itimerval
*const value
,
321 unsigned long long expires
),
323 TP_ARGS(which
, value
, expires
),
326 ctf_integer(int, which
, which
)
327 ctf_integer(unsigned long long, expires
, expires
)
328 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
329 ctf_integer(long, value_usec
, value
->it_value
.tv_usec
)
330 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
331 ctf_integer(long, interval_usec
, value
->it_interval
.tv_usec
)
334 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
335 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
339 TP_PROTO(int which
, const struct itimerval
*const value
,
342 TP_ARGS(which
, value
, expires
),
345 ctf_integer(int, which
, which
)
346 ctf_integer(cputime_t
, expires
, expires
)
347 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
348 ctf_integer(long, value_usec
, value
->it_value
.tv_usec
)
349 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
350 ctf_integer(long, interval_usec
, value
->it_interval
.tv_usec
)
353 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
356 * itimer_expire - called when itimer expires
357 * @which: type of the interval timer
358 * @pid: pid of the process which owns the timer
359 * @now: current time, used to calculate the latency of itimer
361 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
362 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
366 TP_PROTO(int which
, struct pid
*pid
, unsigned long long now
),
368 TP_ARGS(which
, pid
, now
),
371 ctf_integer(int , which
, which
)
372 ctf_integer(pid_t
, pid
, pid_nr(pid
))
373 ctf_integer(unsigned long long, now
, now
)
376 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
377 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
381 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
383 TP_ARGS(which
, pid
, now
),
386 ctf_integer(int , which
, which
)
387 ctf_integer(pid_t
, pid
, pid_nr(pid
))
388 ctf_integer(cputime_t
, now
, now
)
391 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
393 #endif /* LTTNG_TRACE_TIMER_H */
395 /* This part must be outside protection */
396 #include <probes/define_trace.h>