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),
40 * timer_start - called when the timer is started
41 * @timer: pointer to struct timer_list
42 * @expires: the timers expiry time
44 TRACE_EVENT(timer_start,
46 TP_PROTO(struct timer_list *timer,
47 unsigned long expires,
50 TP_ARGS(timer, expires, flags),
53 __field( void *, timer )
54 __field( void *, function )
55 __field( unsigned long, expires )
56 __field( unsigned long, now )
57 __field( unsigned int, flags )
61 __entry->timer = timer;
62 __entry->function = timer->function;
63 __entry->expires = expires;
64 __entry->now = jiffies;
65 __entry->flags = flags;
68 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] flags=0x%08x",
69 __entry->timer, __entry->function, __entry->expires,
70 (long)__entry->expires - __entry->now, __entry->flags)
74 * timer_expire_entry - called immediately before the timer callback
75 * @timer: pointer to struct timer_list
77 * Allows to determine the timer latency.
79 TRACE_EVENT(timer_expire_entry,
81 TP_PROTO(struct timer_list *timer),
86 __field( void *, timer )
87 __field( unsigned long, now )
88 __field( void *, function)
92 __entry->timer = timer;
93 __entry->now = jiffies;
94 __entry->function = timer->function;
97 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
101 * timer_expire_exit - called immediately after the timer callback returns
102 * @timer: pointer to struct timer_list
104 * When used in combination with the timer_expire_entry tracepoint we can
105 * determine the runtime of the timer callback function.
107 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
108 * be invalid. We solely track the pointer.
110 DEFINE_EVENT(timer_class, timer_expire_exit,
112 TP_PROTO(struct timer_list *timer),
118 * timer_cancel - called when the timer is canceled
119 * @timer: pointer to struct timer_list
121 DEFINE_EVENT(timer_class, timer_cancel,
123 TP_PROTO(struct timer_list *timer),
129 * hrtimer_init - called when the hrtimer is initialized
130 * @hrtimer: pointer to struct hrtimer
131 * @clockid: the hrtimers clock
132 * @mode: the hrtimers mode
134 TRACE_EVENT(hrtimer_init,
136 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
137 enum hrtimer_mode mode),
139 TP_ARGS(hrtimer, clockid, mode),
142 __field( void *, hrtimer )
143 __field( clockid_t, clockid )
144 __field( enum hrtimer_mode, mode )
148 __entry->hrtimer = hrtimer;
149 __entry->clockid = clockid;
150 __entry->mode = mode;
153 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
154 __entry->clockid == CLOCK_REALTIME ?
155 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
156 __entry->mode == HRTIMER_MODE_ABS ?
157 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
161 * hrtimer_start - called when the hrtimer is started
162 * @hrtimer: pointer to struct hrtimer
164 TRACE_EVENT(hrtimer_start,
166 TP_PROTO(struct hrtimer *hrtimer),
171 __field( void *, hrtimer )
172 __field( void *, function )
173 __field( s64, expires )
174 __field( s64, softexpires )
178 __entry->hrtimer = hrtimer;
179 __entry->function = hrtimer->function;
180 __entry->expires = hrtimer_get_expires(hrtimer);
181 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
184 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
185 __entry->hrtimer, __entry->function,
186 (unsigned long long) __entry->expires,
187 (unsigned long long) __entry->softexpires)
191 * hrtimer_expire_entry - called immediately before the hrtimer callback
192 * @hrtimer: pointer to struct hrtimer
193 * @now: pointer to variable which contains current time of the
196 * Allows to determine the timer latency.
198 TRACE_EVENT(hrtimer_expire_entry,
200 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
202 TP_ARGS(hrtimer, now),
205 __field( void *, hrtimer )
207 __field( void *, function)
211 __entry->hrtimer = hrtimer;
213 __entry->function = hrtimer->function;
216 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
217 (unsigned long long) __entry->now)
220 DECLARE_EVENT_CLASS(hrtimer_class,
222 TP_PROTO(struct hrtimer *hrtimer),
227 __field( void *, hrtimer )
231 __entry->hrtimer = hrtimer;
234 TP_printk("hrtimer=%p", __entry->hrtimer)
238 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
239 * @hrtimer: pointer to struct hrtimer
241 * When used in combination with the hrtimer_expire_entry tracepoint we can
242 * determine the runtime of the callback function.
244 DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
246 TP_PROTO(struct hrtimer *hrtimer),
252 * hrtimer_cancel - called when the hrtimer is canceled
253 * @hrtimer: pointer to struct hrtimer
255 DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
257 TP_PROTO(struct hrtimer *hrtimer),
263 * itimer_state - called when itimer is started or canceled
264 * @which: name of the interval timer
265 * @value: the itimers value, itimer is canceled if value->it_value is
266 * zero, otherwise it is started
267 * @expires: the itimers expiry time
269 TRACE_EVENT(itimer_state,
271 TP_PROTO(int which, const struct itimerval *const value,
274 TP_ARGS(which, value, expires),
277 __field( int, which )
278 __field( cputime_t, expires )
279 __field( long, value_sec )
280 __field( long, value_usec )
281 __field( long, interval_sec )
282 __field( long, interval_usec )
286 __entry->which = which;
287 __entry->expires = expires;
288 __entry->value_sec = value->it_value.tv_sec;
289 __entry->value_usec = value->it_value.tv_usec;
290 __entry->interval_sec = value->it_interval.tv_sec;
291 __entry->interval_usec = value->it_interval.tv_usec;
294 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
295 __entry->which, (unsigned long long)__entry->expires,
296 __entry->value_sec, __entry->value_usec,
297 __entry->interval_sec, __entry->interval_usec)
301 * itimer_expire - called when itimer expires
302 * @which: type of the interval timer
303 * @pid: pid of the process which owns the timer
304 * @now: current time, used to calculate the latency of itimer
306 TRACE_EVENT(itimer_expire,
308 TP_PROTO(int which, struct pid *pid, cputime_t now),
310 TP_ARGS(which, pid, now),
313 __field( int , which )
314 __field( pid_t, pid )
315 __field( cputime_t, now )
319 __entry->which = which;
321 __entry->pid = pid_nr(pid);
324 TP_printk("which=%d pid=%d now=%llu", __entry->which,
325 (int) __entry->pid, (unsigned long long)__entry->now)
328 #ifdef CONFIG_NO_HZ_COMMON
330 #define TICK_DEP_NAMES \
331 tick_dep_mask_name(NONE) \
332 tick_dep_name(POSIX_TIMER) \
333 tick_dep_name(PERF_EVENTS) \
334 tick_dep_name(SCHED) \
335 tick_dep_name_end(CLOCK_UNSTABLE)
338 #undef tick_dep_mask_name
339 #undef tick_dep_name_end
341 /* The MASK will convert to their bits and they need to be processed too */
342 #define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
343 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
344 #define tick_dep_name_end(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
345 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
346 /* NONE only has a mask defined for it */
347 #define tick_dep_mask_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
352 #undef tick_dep_mask_name
353 #undef tick_dep_name_end
355 #define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
356 #define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
357 #define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
359 #define show_tick_dep_name(val) \
360 __print_symbolic(val, TICK_DEP_NAMES)
362 TRACE_EVENT(tick_stop,
364 TP_PROTO(int success, int dependency),
366 TP_ARGS(success, dependency),
369 __field( int , success )
370 __field( int , dependency )
374 __entry->success = success;
375 __entry->dependency = dependency;
378 TP_printk("success=%d dependency=%s", __entry->success, \
379 show_tick_dep_name(__entry->dependency))
383 #endif /* _TRACE_TIMER_H */
385 /* This part must be outside protection */
386 #include <trace/define_trace.h>