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 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
21 TP_PROTO(struct timer_list
*timer
),
26 ctf_integer_hex(void *, timer
, timer
)
31 * timer_init - called when the timer is initialized
32 * @timer: pointer to struct timer_list
34 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
36 TP_PROTO(struct timer_list
*timer
),
41 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0))
43 * timer_start - called when the timer is started
44 * @timer: pointer to struct timer_list
45 * @expires: the timers expiry time
46 * @flags: the timers expiry time
48 LTTNG_TRACEPOINT_EVENT(timer_start
,
50 TP_PROTO(struct timer_list
*timer
, unsigned long expires
,
53 TP_ARGS(timer
, expires
, flags
),
56 ctf_integer_hex(void *, timer
, timer
)
57 ctf_integer_hex(void *, function
, timer
->function
)
58 ctf_integer(unsigned long, expires
, expires
)
59 ctf_integer(unsigned long, now
, jiffies
)
60 ctf_integer(unsigned int, flags
, flags
)
63 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
65 * timer_start - called when the timer is started
66 * @timer: pointer to struct timer_list
67 * @expires: the timers expiry time
69 LTTNG_TRACEPOINT_EVENT(timer_start
,
71 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
73 TP_ARGS(timer
, expires
),
76 ctf_integer_hex(void *, timer
, timer
)
77 ctf_integer_hex(void *, function
, timer
->function
)
78 ctf_integer(unsigned long, expires
, expires
)
79 ctf_integer(unsigned long, now
, jiffies
)
82 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
85 * timer_expire_entry - called immediately before the timer callback
86 * @timer: pointer to struct timer_list
88 * Allows to determine the timer latency.
90 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
92 TP_PROTO(struct timer_list
*timer
),
97 ctf_integer_hex(void *, timer
, timer
)
98 ctf_integer(unsigned long, now
, jiffies
)
99 ctf_integer_hex(void *, function
, timer
->function
)
104 * timer_expire_exit - called immediately after the timer callback returns
105 * @timer: pointer to struct timer_list
107 * When used in combination with the timer_expire_entry tracepoint we can
108 * determine the runtime of the timer callback function.
110 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
111 * be invalid. We solely track the pointer.
113 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_expire_exit
,
115 TP_PROTO(struct timer_list
*timer
),
121 * timer_cancel - called when the timer is canceled
122 * @timer: pointer to struct timer_list
124 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_cancel
,
126 TP_PROTO(struct timer_list
*timer
),
132 * hrtimer_init - called when the hrtimer is initialized
133 * @timer: pointer to struct hrtimer
134 * @clockid: the hrtimers clock
135 * @mode: the hrtimers mode
137 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init
,
141 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
142 enum hrtimer_mode mode
),
144 TP_ARGS(hrtimer
, clockid
, mode
),
147 ctf_integer_hex(void *, hrtimer
, hrtimer
)
148 ctf_integer(clockid_t
, clockid
, clockid
)
149 ctf_integer(enum hrtimer_mode
, mode
, mode
)
154 * hrtimer_start - called when the hrtimer is started
155 * @timer: pointer to struct hrtimer
157 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
161 TP_PROTO(struct hrtimer
*hrtimer
),
166 ctf_integer_hex(void *, hrtimer
, hrtimer
)
167 ctf_integer_hex(void *, function
, hrtimer
->function
)
168 ctf_integer(s64
, expires
, hrtimer_get_expires(hrtimer
).tv64
)
169 ctf_integer(s64
, softexpires
, hrtimer_get_softexpires(hrtimer
).tv64
)
174 * htimmer_expire_entry - called immediately before the hrtimer callback
175 * @timer: pointer to struct hrtimer
176 * @now: pointer to variable which contains current time of the
179 * Allows to determine the timer latency.
181 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry
,
183 timer_hrtimer_expire_entry
,
185 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
187 TP_ARGS(hrtimer
, now
),
190 ctf_integer_hex(void *, hrtimer
, hrtimer
)
191 ctf_integer(s64
, now
, now
->tv64
)
192 ctf_integer_hex(void *, function
, hrtimer
->function
)
196 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class
,
198 TP_PROTO(struct hrtimer
*hrtimer
),
203 ctf_integer_hex(void *, hrtimer
, hrtimer
)
208 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
209 * @timer: pointer to struct hrtimer
211 * When used in combination with the hrtimer_expire_entry tracepoint we can
212 * determine the runtime of the callback function.
214 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_expire_exit
,
216 timer_hrtimer_expire_exit
,
218 TP_PROTO(struct hrtimer
*hrtimer
),
224 * hrtimer_cancel - called when the hrtimer is canceled
225 * @hrtimer: pointer to struct hrtimer
227 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_cancel
,
229 timer_hrtimer_cancel
,
231 TP_PROTO(struct hrtimer
*hrtimer
),
237 * itimer_state - called when itimer is started or canceled
238 * @which: name of the interval timer
239 * @value: the itimers value, itimer is canceled if value->it_value is
240 * zero, otherwise it is started
241 * @expires: the itimers expiry time
243 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
247 TP_PROTO(int which
, const struct itimerval
*const value
,
250 TP_ARGS(which
, value
, expires
),
253 ctf_integer(int, which
, which
)
254 ctf_integer(cputime_t
, expires
, expires
)
255 ctf_integer(long, value_sec
, value
->it_value
.tv_sec
)
256 ctf_integer(long, value_usec
, value
->it_value
.tv_usec
)
257 ctf_integer(long, interval_sec
, value
->it_interval
.tv_sec
)
258 ctf_integer(long, interval_usec
, value
->it_interval
.tv_usec
)
263 * itimer_expire - called when itimer expires
264 * @which: type of the interval timer
265 * @pid: pid of the process which owns the timer
266 * @now: current time, used to calculate the latency of itimer
268 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
272 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
274 TP_ARGS(which
, pid
, now
),
277 ctf_integer(int , which
, which
)
278 ctf_integer(pid_t
, pid
, pid_nr(pid
))
279 ctf_integer(cputime_t
, now
, now
)
283 #endif /* LTTNG_TRACE_TIMER_H */
285 /* This part must be outside protection */
286 #include "../../../probes/define_trace.h"