2 #define TRACE_SYSTEM timer
4 #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/tracepoint.h>
8 #include <linux/hrtimer.h>
9 #include <linux/timer.h>
12 * timer_init - called when the timer is initialized
13 * @timer: pointer to struct timer_list
15 TRACE_EVENT(timer_init
,
17 TP_PROTO(struct timer_list
*timer
),
22 __field( void *, timer
)
26 __entry
->timer
= timer
;
29 TP_printk("timer %p", __entry
->timer
)
33 * timer_start - called when the timer is started
34 * @timer: pointer to struct timer_list
35 * @expires: the timers expiry time
37 TRACE_EVENT(timer_start
,
39 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
41 TP_ARGS(timer
, expires
),
44 __field( void *, timer
)
45 __field( void *, function
)
46 __field( unsigned long, expires
)
47 __field( unsigned long, now
)
51 __entry
->timer
= timer
;
52 __entry
->function
= timer
->function
;
53 __entry
->expires
= expires
;
54 __entry
->now
= jiffies
;
57 TP_printk("timer %p: func %pf, expires %lu, timeout %ld",
58 __entry
->timer
, __entry
->function
, __entry
->expires
,
59 (long)__entry
->expires
- __entry
->now
)
63 * timer_expire_entry - called immediately before the timer callback
64 * @timer: pointer to struct timer_list
66 * Allows to determine the timer latency.
68 TRACE_EVENT(timer_expire_entry
,
70 TP_PROTO(struct timer_list
*timer
),
75 __field( void *, timer
)
76 __field( unsigned long, now
)
80 __entry
->timer
= timer
;
81 __entry
->now
= jiffies
;
84 TP_printk("timer %p: now %lu", __entry
->timer
, __entry
->now
)
88 * timer_expire_exit - called immediately after the timer callback returns
89 * @timer: pointer to struct timer_list
91 * When used in combination with the timer_expire_entry tracepoint we can
92 * determine the runtime of the timer callback function.
94 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
95 * be invalid. We solely track the pointer.
97 TRACE_EVENT(timer_expire_exit
,
99 TP_PROTO(struct timer_list
*timer
),
104 __field(void *, timer
)
108 __entry
->timer
= timer
;
111 TP_printk("timer %p", __entry
->timer
)
115 * timer_cancel - called when the timer is canceled
116 * @timer: pointer to struct timer_list
118 TRACE_EVENT(timer_cancel
,
120 TP_PROTO(struct timer_list
*timer
),
125 __field( void *, timer
)
129 __entry
->timer
= timer
;
132 TP_printk("timer %p", __entry
->timer
)
136 * hrtimer_init - called when the hrtimer is initialized
137 * @timer: pointer to struct hrtimer
138 * @clockid: the hrtimers clock
139 * @mode: the hrtimers mode
141 TRACE_EVENT(hrtimer_init
,
143 TP_PROTO(struct hrtimer
*timer
, clockid_t clockid
,
144 enum hrtimer_mode mode
),
146 TP_ARGS(timer
, clockid
, mode
),
149 __field( void *, timer
)
150 __field( clockid_t
, clockid
)
151 __field( enum hrtimer_mode
, mode
)
155 __entry
->timer
= timer
;
156 __entry
->clockid
= clockid
;
157 __entry
->mode
= mode
;
160 TP_printk("hrtimer %p, clockid %s, mode %s", __entry
->timer
,
161 __entry
->clockid
== CLOCK_REALTIME
?
162 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
163 __entry
->mode
== HRTIMER_MODE_ABS
?
164 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
168 * hrtimer_start - called when the hrtimer is started
169 * @timer: pointer to struct hrtimer
171 TRACE_EVENT(hrtimer_start
,
173 TP_PROTO(struct hrtimer
*timer
),
178 __field( void *, timer
)
179 __field( void *, function
)
180 __field( s64
, expires
)
181 __field( s64
, softexpires
)
185 __entry
->timer
= timer
;
186 __entry
->function
= timer
->function
;
187 __entry
->expires
= hrtimer_get_expires(timer
).tv64
;
188 __entry
->softexpires
= hrtimer_get_softexpires(timer
).tv64
;
191 TP_printk("hrtimer %p, func %pf, expires %llu, softexpires %llu",
192 __entry
->timer
, __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 TRACE_EVENT(hrtimer_expire_entry
,
209 TP_PROTO(struct hrtimer
*timer
, ktime_t
*now
),
214 __field( void *, timer
)
219 __entry
->timer
= timer
;
220 __entry
->now
= now
->tv64
;
223 TP_printk("hrtimer %p, now %llu", __entry
->timer
,
224 (unsigned long long)ktime_to_ns((ktime_t
) {
225 .tv64
= __entry
->now
}))
229 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
230 * @timer: pointer to struct hrtimer
232 * When used in combination with the hrtimer_expire_entry tracepoint we can
233 * determine the runtime of the callback function.
235 TRACE_EVENT(hrtimer_expire_exit
,
237 TP_PROTO(struct hrtimer
*timer
),
242 __field( void *, timer
)
246 __entry
->timer
= timer
;
249 TP_printk("hrtimer %p", __entry
->timer
)
253 * hrtimer_cancel - called when the hrtimer is canceled
254 * @timer: pointer to struct hrtimer
256 TRACE_EVENT(hrtimer_cancel
,
258 TP_PROTO(struct hrtimer
*timer
),
263 __field( void *, timer
)
267 __entry
->timer
= timer
;
270 TP_printk("hrtimer %p", __entry
->timer
)
274 * itimer_state - called when itimer is started or canceled
275 * @which: name of the interval timer
276 * @value: the itimers value, itimer is canceled if value->it_value is
277 * zero, otherwise it is started
278 * @expires: the itimers expiry time
280 TRACE_EVENT(itimer_state
,
282 TP_PROTO(int which
, const struct itimerval
*const value
,
285 TP_ARGS(which
, value
, expires
),
288 __field( int, which
)
289 __field( cputime_t
, expires
)
290 __field( long, value_sec
)
291 __field( long, value_usec
)
292 __field( long, interval_sec
)
293 __field( long, interval_usec
)
297 __entry
->which
= which
;
298 __entry
->expires
= expires
;
299 __entry
->value_sec
= value
->it_value
.tv_sec
;
300 __entry
->value_usec
= value
->it_value
.tv_usec
;
301 __entry
->interval_sec
= value
->it_interval
.tv_sec
;
302 __entry
->interval_usec
= value
->it_interval
.tv_usec
;
305 TP_printk("which %d, expires %lu, it_value %lu.%lu, it_interval %lu.%lu",
306 __entry
->which
, __entry
->expires
,
307 __entry
->value_sec
, __entry
->value_usec
,
308 __entry
->interval_sec
, __entry
->interval_usec
)
312 * itimer_expire - called when itimer expires
313 * @which: type of the interval timer
314 * @pid: pid of the process which owns the timer
315 * @now: current time, used to calculate the latency of itimer
317 TRACE_EVENT(itimer_expire
,
319 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
321 TP_ARGS(which
, pid
, now
),
324 __field( int , which
)
325 __field( pid_t
, pid
)
326 __field( cputime_t
, now
)
330 __entry
->which
= which
;
332 __entry
->pid
= pid_nr(pid
);
335 TP_printk("which %d, pid %d, now %lu", __entry
->which
,
336 (int) __entry
->pid
, __entry
->now
)
339 #endif /* _TRACE_TIMER_H */
341 /* This part must be outside protection */
342 #include <trace/define_trace.h>