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 <probes/lttng-tracepoint-event.h>
10 #ifndef _TRACE_TIMER_DEF_
11 #define _TRACE_TIMER_DEF_
12 #include <linux/hrtimer.h>
13 #include <linux/timer.h>
17 #endif /* _TRACE_TIMER_DEF_ */
19 #define lttng_ktime_get_tv64(kt) (kt)
21 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
23 TP_PROTO(struct timer_list
*timer
),
28 ctf_integer_hex(void *, timer
, timer
)
33 * timer_init - called when the timer is initialized
34 * @timer: pointer to struct timer_list
36 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
38 TP_PROTO(struct timer_list
*timer
),
44 * timer_start - called when the timer is started
45 * @timer: pointer to struct timer_list
46 * @expires: the timers expiry time
47 * @flags: the timers expiry time
49 LTTNG_TRACEPOINT_EVENT(timer_start
,
51 TP_PROTO(struct timer_list
*timer
, unsigned long expires
,
54 TP_ARGS(timer
, expires
, flags
),
57 ctf_integer_hex(void *, timer
, timer
)
58 ctf_integer_hex(void *, function
, timer
->function
)
59 ctf_integer(unsigned long, expires
, expires
)
60 ctf_integer(unsigned long, now
, jiffies
)
61 ctf_integer(unsigned int, flags
, flags
)
66 * timer_expire_entry - called immediately before the timer callback
67 * @timer: pointer to struct timer_list
69 * Allows to determine the timer latency.
71 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
73 TP_PROTO(struct timer_list
*timer
, unsigned long baseclk
),
75 TP_ARGS(timer
, baseclk
),
78 ctf_integer_hex(void *, timer
, timer
)
79 ctf_integer(unsigned long, now
, jiffies
)
80 ctf_integer_hex(void *, function
, timer
->function
)
81 ctf_integer(unsigned long, baseclk
, baseclk
)
86 * timer_expire_exit - called immediately after the timer callback returns
87 * @timer: pointer to struct timer_list
89 * When used in combination with the timer_expire_entry tracepoint we can
90 * determine the runtime of the timer callback function.
92 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
93 * be invalid. We solely track the pointer.
95 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_expire_exit
,
97 TP_PROTO(struct timer_list
*timer
),
103 * timer_cancel - called when the timer is canceled
104 * @timer: pointer to struct timer_list
106 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_cancel
,
108 TP_PROTO(struct timer_list
*timer
),
114 * hrtimer_init - called when the hrtimer is initialized
115 * @timer: pointer to struct hrtimer
116 * @clockid: the hrtimers clock
117 * @mode: the hrtimers mode
119 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init
,
123 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
124 enum hrtimer_mode mode
),
126 TP_ARGS(hrtimer
, clockid
, mode
),
129 ctf_integer_hex(void *, hrtimer
, hrtimer
)
130 ctf_integer(clockid_t
, clockid
, clockid
)
131 ctf_integer(enum hrtimer_mode
, mode
, mode
)
136 * hrtimer_start - called when the hrtimer is started
137 * @timer: pointer to struct hrtimer
139 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
143 TP_PROTO(struct hrtimer
*hrtimer
, enum hrtimer_mode mode
),
145 TP_ARGS(hrtimer
, mode
),
148 ctf_integer_hex(void *, hrtimer
, hrtimer
)
149 ctf_integer_hex(void *, function
, hrtimer
->function
)
150 ctf_integer(s64
, expires
,
151 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer
)))
152 ctf_integer(s64
, softexpires
,
153 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer
)))
154 ctf_integer(enum hrtimer_mode
, mode
, mode
)
159 * htimmer_expire_entry - called immediately before the hrtimer callback
160 * @timer: pointer to struct hrtimer
161 * @now: pointer to variable which contains current time of the
164 * Allows to determine the timer latency.
166 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry
,
168 timer_hrtimer_expire_entry
,
170 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
172 TP_ARGS(hrtimer
, now
),
175 ctf_integer_hex(void *, hrtimer
, hrtimer
)
176 ctf_integer(s64
, now
, lttng_ktime_get_tv64(*now
))
177 ctf_integer_hex(void *, function
, hrtimer
->function
)
181 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class
,
183 TP_PROTO(struct hrtimer
*hrtimer
),
188 ctf_integer_hex(void *, hrtimer
, hrtimer
)
193 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
194 * @timer: pointer to struct hrtimer
196 * When used in combination with the hrtimer_expire_entry tracepoint we can
197 * determine the runtime of the callback function.
199 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_expire_exit
,
201 timer_hrtimer_expire_exit
,
203 TP_PROTO(struct hrtimer
*hrtimer
),
209 * hrtimer_cancel - called when the hrtimer is canceled
210 * @hrtimer: pointer to struct hrtimer
212 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_cancel
,
214 timer_hrtimer_cancel
,
216 TP_PROTO(struct hrtimer
*hrtimer
),
222 * itimer_state - called when itimer is started or canceled
223 * @which: name of the interval timer
224 * @value: the itimers value, itimer is canceled if value->it_value is
225 * zero, otherwise it is started
226 * @expires: the itimers expiry time
228 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
232 TP_PROTO(int which
, const struct itimerspec64
*const value
,
233 unsigned long long expires
),
235 TP_ARGS(which
, value
, expires
),
238 ctf_integer(int, which
, which
)
239 ctf_integer(unsigned long long, expires
, expires
)
240 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
241 ctf_integer(long, value_nsec
, value
->it_value
.tv_nsec
)
242 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
243 ctf_integer(long, interval_nsec
, value
->it_interval
.tv_nsec
)
248 * itimer_expire - called when itimer expires
249 * @which: type of the interval timer
250 * @pid: pid of the process which owns the timer
251 * @now: current time, used to calculate the latency of itimer
253 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
257 TP_PROTO(int which
, struct pid
*pid
, unsigned long long now
),
259 TP_ARGS(which
, pid
, now
),
262 ctf_integer(int , which
, which
)
263 ctf_integer(pid_t
, pid
, pid_nr(pid
))
264 ctf_integer(unsigned long long, now
, now
)
268 #endif /* LTTNG_TRACE_TIMER_H */
270 /* This part must be outside protection */
271 #include <probes/define_trace.h>