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>
16 #endif /* _TRACE_TIMER_DEF_ */
18 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
20 TP_PROTO(struct timer_list
*timer
),
25 __field( void *, timer
)
29 tp_assign(timer
, timer
)
32 TP_printk("timer=%p", __entry
->timer
)
36 * timer_init - called when the timer is initialized
37 * @timer: pointer to struct timer_list
39 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
41 TP_PROTO(struct timer_list
*timer
),
47 * timer_start - called when the timer is started
48 * @timer: pointer to struct timer_list
49 * @expires: the timers expiry time
51 LTTNG_TRACEPOINT_EVENT(timer_start
,
53 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
55 TP_ARGS(timer
, expires
),
58 __field( void *, timer
)
59 __field( void *, function
)
60 __field( unsigned long, expires
)
61 __field( unsigned long, now
)
65 tp_assign(timer
, timer
)
66 tp_assign(function
, timer
->function
)
67 tp_assign(expires
, expires
)
68 tp_assign(now
, jiffies
)
71 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
72 __entry
->timer
, __entry
->function
, __entry
->expires
,
73 (long)__entry
->expires
- __entry
->now
)
77 * timer_expire_entry - called immediately before the timer callback
78 * @timer: pointer to struct timer_list
80 * Allows to determine the timer latency.
82 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
84 TP_PROTO(struct timer_list
*timer
),
89 __field( void *, timer
)
90 __field( unsigned long, now
)
91 __field( void *, function
)
95 tp_assign(timer
, timer
)
96 tp_assign(now
, jiffies
)
97 tp_assign(function
, timer
->function
)
100 TP_printk("timer=%p function=%pf now=%lu", __entry
->timer
, __entry
->function
,__entry
->now
)
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 __field( void *, hrtimer
)
148 __field( clockid_t
, clockid
)
149 __field( enum hrtimer_mode
, mode
)
153 tp_assign(hrtimer
, hrtimer
)
154 tp_assign(clockid
, clockid
)
155 tp_assign(mode
, mode
)
158 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry
->hrtimer
,
159 __entry
->clockid
== CLOCK_REALTIME
?
160 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
161 __entry
->mode
== HRTIMER_MODE_ABS
?
162 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
166 * hrtimer_start - called when the hrtimer is started
167 * @timer: pointer to struct hrtimer
169 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start
,
173 TP_PROTO(struct hrtimer
*hrtimer
),
178 __field( void *, hrtimer
)
179 __field( void *, function
)
180 __field( s64
, expires
)
181 __field( s64
, softexpires
)
185 tp_assign(hrtimer
, hrtimer
)
186 tp_assign(function
, hrtimer
->function
)
187 tp_assign(expires
, hrtimer_get_expires(hrtimer
).tv64
)
188 tp_assign(softexpires
, hrtimer_get_softexpires(hrtimer
).tv64
)
191 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
192 __entry
->hrtimer
, __entry
->function
,
193 (unsigned long long)ktime_to_ns((ktime_t
) {
194 .tv64
= __entry
->expires
}),
195 (unsigned long long)ktime_to_ns((ktime_t
) {
196 .tv64
= __entry
->softexpires
}))
200 * htimmer_expire_entry - called immediately before the hrtimer callback
201 * @timer: pointer to struct hrtimer
202 * @now: pointer to variable which contains current time of the
205 * Allows to determine the timer latency.
207 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry
,
209 timer_hrtimer_expire_entry
,
211 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
213 TP_ARGS(hrtimer
, now
),
216 __field( void *, hrtimer
)
218 __field( void *, function
)
222 tp_assign(hrtimer
, hrtimer
)
223 tp_assign(now
, now
->tv64
)
224 tp_assign(function
, hrtimer
->function
)
227 TP_printk("hrtimer=%p function=%pf now=%llu", __entry
->hrtimer
, __entry
->function
,
228 (unsigned long long)ktime_to_ns((ktime_t
) { .tv64
= __entry
->now
}))
231 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class
,
233 TP_PROTO(struct hrtimer
*hrtimer
),
238 __field( void *, hrtimer
)
242 tp_assign(hrtimer
, hrtimer
)
245 TP_printk("hrtimer=%p", __entry
->hrtimer
)
249 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
250 * @timer: pointer to struct hrtimer
252 * When used in combination with the hrtimer_expire_entry tracepoint we can
253 * determine the runtime of the callback function.
255 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_expire_exit
,
257 timer_hrtimer_expire_exit
,
259 TP_PROTO(struct hrtimer
*hrtimer
),
265 * hrtimer_cancel - called when the hrtimer is canceled
266 * @hrtimer: pointer to struct hrtimer
268 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class
, hrtimer_cancel
,
270 timer_hrtimer_cancel
,
272 TP_PROTO(struct hrtimer
*hrtimer
),
278 * itimer_state - called when itimer is started or canceled
279 * @which: name of the interval timer
280 * @value: the itimers value, itimer is canceled if value->it_value is
281 * zero, otherwise it is started
282 * @expires: the itimers expiry time
284 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state
,
288 TP_PROTO(int which
, const struct itimerval
*const value
,
291 TP_ARGS(which
, value
, expires
),
294 __field( int, which
)
295 __field( cputime_t
, expires
)
296 __field( long, value_sec
)
297 __field( long, value_usec
)
298 __field( long, interval_sec
)
299 __field( long, interval_usec
)
303 tp_assign(which
, which
)
304 tp_assign(expires
, expires
)
305 tp_assign(value_sec
, value
->it_value
.tv_sec
)
306 tp_assign(value_usec
, value
->it_value
.tv_usec
)
307 tp_assign(interval_sec
, value
->it_interval
.tv_sec
)
308 tp_assign(interval_usec
, value
->it_interval
.tv_usec
)
311 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
312 __entry
->which
, (unsigned long long)__entry
->expires
,
313 __entry
->value_sec
, __entry
->value_usec
,
314 __entry
->interval_sec
, __entry
->interval_usec
)
318 * itimer_expire - called when itimer expires
319 * @which: type of the interval timer
320 * @pid: pid of the process which owns the timer
321 * @now: current time, used to calculate the latency of itimer
323 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire
,
327 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
329 TP_ARGS(which
, pid
, now
),
332 __field( int , which
)
333 __field( pid_t
, pid
)
334 __field( cputime_t
, now
)
338 tp_assign(which
, which
)
340 tp_assign(pid
, pid_nr(pid
))
343 TP_printk("which=%d pid=%d now=%llu", __entry
->which
,
344 (int) __entry
->pid
, (unsigned long long)__entry
->now
)
347 #endif /* LTTNG_TRACE_TIMER_H */
349 /* This part must be outside protection */
350 #include "../../../probes/define_trace.h"