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>
11 DECLARE_EVENT_CLASS(timer_class
,
13 TP_PROTO(struct timer_list
*timer
),
18 __field( void *, timer
)
22 __entry
->timer
= timer
;
25 TP_printk("timer=%p", __entry
->timer
)
29 * timer_init - called when the timer is initialized
30 * @timer: pointer to struct timer_list
32 DEFINE_EVENT(timer_class
, timer_init
,
34 TP_PROTO(struct timer_list
*timer
),
39 #define decode_timer_flags(flags) \
40 __print_flags(flags, "|", \
41 { TIMER_MIGRATING, "M" }, \
42 { TIMER_DEFERRABLE, "D" }, \
43 { TIMER_PINNED, "P" }, \
44 { TIMER_IRQSAFE, "I" })
47 * timer_start - called when the timer is started
48 * @timer: pointer to struct timer_list
49 * @expires: the timers expiry time
51 TRACE_EVENT(timer_start
,
53 TP_PROTO(struct timer_list
*timer
,
54 unsigned long expires
,
57 TP_ARGS(timer
, expires
, flags
),
60 __field( void *, timer
)
61 __field( void *, function
)
62 __field( unsigned long, expires
)
63 __field( unsigned long, now
)
64 __field( unsigned int, flags
)
68 __entry
->timer
= timer
;
69 __entry
->function
= timer
->function
;
70 __entry
->expires
= expires
;
71 __entry
->now
= jiffies
;
72 __entry
->flags
= flags
;
75 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
76 __entry
->timer
, __entry
->function
, __entry
->expires
,
77 (long)__entry
->expires
- __entry
->now
,
78 __entry
->flags
& TIMER_CPUMASK
,
79 __entry
->flags
>> TIMER_ARRAYSHIFT
,
80 decode_timer_flags(__entry
->flags
& TIMER_TRACE_FLAGMASK
))
84 * timer_expire_entry - called immediately before the timer callback
85 * @timer: pointer to struct timer_list
87 * Allows to determine the timer latency.
89 TRACE_EVENT(timer_expire_entry
,
91 TP_PROTO(struct timer_list
*timer
),
96 __field( void *, timer
)
97 __field( unsigned long, now
)
98 __field( void *, function
)
102 __entry
->timer
= timer
;
103 __entry
->now
= jiffies
;
104 __entry
->function
= timer
->function
;
107 TP_printk("timer=%p function=%pf now=%lu", __entry
->timer
, __entry
->function
,__entry
->now
)
111 * timer_expire_exit - called immediately after the timer callback returns
112 * @timer: pointer to struct timer_list
114 * When used in combination with the timer_expire_entry tracepoint we can
115 * determine the runtime of the timer callback function.
117 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
118 * be invalid. We solely track the pointer.
120 DEFINE_EVENT(timer_class
, timer_expire_exit
,
122 TP_PROTO(struct timer_list
*timer
),
128 * timer_cancel - called when the timer is canceled
129 * @timer: pointer to struct timer_list
131 DEFINE_EVENT(timer_class
, timer_cancel
,
133 TP_PROTO(struct timer_list
*timer
),
139 * hrtimer_init - called when the hrtimer is initialized
140 * @hrtimer: pointer to struct hrtimer
141 * @clockid: the hrtimers clock
142 * @mode: the hrtimers mode
144 TRACE_EVENT(hrtimer_init
,
146 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
147 enum hrtimer_mode mode
),
149 TP_ARGS(hrtimer
, clockid
, mode
),
152 __field( void *, hrtimer
)
153 __field( clockid_t
, clockid
)
154 __field( enum hrtimer_mode
, mode
)
158 __entry
->hrtimer
= hrtimer
;
159 __entry
->clockid
= clockid
;
160 __entry
->mode
= mode
;
163 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry
->hrtimer
,
164 __entry
->clockid
== CLOCK_REALTIME
?
165 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
166 __entry
->mode
== HRTIMER_MODE_ABS
?
167 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
171 * hrtimer_start - called when the hrtimer is started
172 * @hrtimer: pointer to struct hrtimer
174 TRACE_EVENT(hrtimer_start
,
176 TP_PROTO(struct hrtimer
*hrtimer
),
181 __field( void *, hrtimer
)
182 __field( void *, function
)
183 __field( s64
, expires
)
184 __field( s64
, softexpires
)
188 __entry
->hrtimer
= hrtimer
;
189 __entry
->function
= hrtimer
->function
;
190 __entry
->expires
= hrtimer_get_expires(hrtimer
);
191 __entry
->softexpires
= hrtimer_get_softexpires(hrtimer
);
194 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
195 __entry
->hrtimer
, __entry
->function
,
196 (unsigned long long) __entry
->expires
,
197 (unsigned long long) __entry
->softexpires
)
201 * hrtimer_expire_entry - called immediately before the hrtimer callback
202 * @hrtimer: pointer to struct hrtimer
203 * @now: pointer to variable which contains current time of the
206 * Allows to determine the timer latency.
208 TRACE_EVENT(hrtimer_expire_entry
,
210 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
212 TP_ARGS(hrtimer
, now
),
215 __field( void *, hrtimer
)
217 __field( void *, function
)
221 __entry
->hrtimer
= hrtimer
;
223 __entry
->function
= hrtimer
->function
;
226 TP_printk("hrtimer=%p function=%pf now=%llu", __entry
->hrtimer
, __entry
->function
,
227 (unsigned long long) __entry
->now
)
230 DECLARE_EVENT_CLASS(hrtimer_class
,
232 TP_PROTO(struct hrtimer
*hrtimer
),
237 __field( void *, hrtimer
)
241 __entry
->hrtimer
= hrtimer
;
244 TP_printk("hrtimer=%p", __entry
->hrtimer
)
248 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
249 * @hrtimer: pointer to struct hrtimer
251 * When used in combination with the hrtimer_expire_entry tracepoint we can
252 * determine the runtime of the callback function.
254 DEFINE_EVENT(hrtimer_class
, hrtimer_expire_exit
,
256 TP_PROTO(struct hrtimer
*hrtimer
),
262 * hrtimer_cancel - called when the hrtimer is canceled
263 * @hrtimer: pointer to struct hrtimer
265 DEFINE_EVENT(hrtimer_class
, hrtimer_cancel
,
267 TP_PROTO(struct hrtimer
*hrtimer
),
273 * itimer_state - called when itimer is started or canceled
274 * @which: name of the interval timer
275 * @value: the itimers value, itimer is canceled if value->it_value is
276 * zero, otherwise it is started
277 * @expires: the itimers expiry time
279 TRACE_EVENT(itimer_state
,
281 TP_PROTO(int which
, const struct itimerval
*const value
,
282 unsigned long long expires
),
284 TP_ARGS(which
, value
, expires
),
287 __field( int, which
)
288 __field( unsigned long long, expires
)
289 __field( long, value_sec
)
290 __field( long, value_usec
)
291 __field( long, interval_sec
)
292 __field( long, interval_usec
)
296 __entry
->which
= which
;
297 __entry
->expires
= expires
;
298 __entry
->value_sec
= value
->it_value
.tv_sec
;
299 __entry
->value_usec
= value
->it_value
.tv_usec
;
300 __entry
->interval_sec
= value
->it_interval
.tv_sec
;
301 __entry
->interval_usec
= value
->it_interval
.tv_usec
;
304 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
305 __entry
->which
, __entry
->expires
,
306 __entry
->value_sec
, __entry
->value_usec
,
307 __entry
->interval_sec
, __entry
->interval_usec
)
311 * itimer_expire - called when itimer expires
312 * @which: type of the interval timer
313 * @pid: pid of the process which owns the timer
314 * @now: current time, used to calculate the latency of itimer
316 TRACE_EVENT(itimer_expire
,
318 TP_PROTO(int which
, struct pid
*pid
, unsigned long long now
),
320 TP_ARGS(which
, pid
, now
),
323 __field( int , which
)
324 __field( pid_t
, pid
)
325 __field( unsigned long long, now
)
329 __entry
->which
= which
;
331 __entry
->pid
= pid_nr(pid
);
334 TP_printk("which=%d pid=%d now=%llu", __entry
->which
,
335 (int) __entry
->pid
, __entry
->now
)
338 #ifdef CONFIG_NO_HZ_COMMON
340 #define TICK_DEP_NAMES \
341 tick_dep_mask_name(NONE) \
342 tick_dep_name(POSIX_TIMER) \
343 tick_dep_name(PERF_EVENTS) \
344 tick_dep_name(SCHED) \
345 tick_dep_name_end(CLOCK_UNSTABLE)
348 #undef tick_dep_mask_name
349 #undef tick_dep_name_end
351 /* The MASK will convert to their bits and they need to be processed too */
352 #define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
353 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
354 #define tick_dep_name_end(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
355 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
356 /* NONE only has a mask defined for it */
357 #define tick_dep_mask_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
362 #undef tick_dep_mask_name
363 #undef tick_dep_name_end
365 #define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
366 #define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
367 #define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
369 #define show_tick_dep_name(val) \
370 __print_symbolic(val, TICK_DEP_NAMES)
372 TRACE_EVENT(tick_stop
,
374 TP_PROTO(int success
, int dependency
),
376 TP_ARGS(success
, dependency
),
379 __field( int , success
)
380 __field( int , dependency
)
384 __entry
->success
= success
;
385 __entry
->dependency
= dependency
;
388 TP_printk("success=%d dependency=%s", __entry
->success
, \
389 show_tick_dep_name(__entry
->dependency
))
393 #endif /* _TRACE_TIMER_H */
395 /* This part must be outside protection */
396 #include <trace/define_trace.h>