blob: 80787eafba99f485f4dd5f32dc72e0e7902dd5a1 [file] [log] [blame]
Xiao Guangrong2b022e32009-08-10 10:48:59 +08001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM timer
3
4#if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_TIMER_H
6
7#include <linux/tracepoint.h>
Xiao Guangrongc6a2a172009-08-10 10:51:23 +08008#include <linux/hrtimer.h>
Xiao Guangrong2b022e32009-08-10 10:48:59 +08009#include <linux/timer.h>
10
Li Zefan363d0f62010-05-24 16:23:15 +080011DECLARE_EVENT_CLASS(timer_class,
Xiao Guangrong2b022e32009-08-10 10:48:59 +080012
13 TP_PROTO(struct timer_list *timer),
14
15 TP_ARGS(timer),
16
17 TP_STRUCT__entry(
18 __field( void *, timer )
19 ),
20
21 TP_fast_assign(
22 __entry->timer = timer;
23 ),
24
Ingo Molnar434a83c2009-10-15 11:50:39 +020025 TP_printk("timer=%p", __entry->timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080026);
27
28/**
Li Zefan363d0f62010-05-24 16:23:15 +080029 * timer_init - called when the timer is initialized
30 * @timer: pointer to struct timer_list
31 */
32DEFINE_EVENT(timer_class, timer_init,
33
34 TP_PROTO(struct timer_list *timer),
35
36 TP_ARGS(timer)
37);
38
Thomas Gleixner8a58a342017-02-10 16:41:15 +010039#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" })
45
Li Zefan363d0f62010-05-24 16:23:15 +080046/**
Xiao Guangrong2b022e32009-08-10 10:48:59 +080047 * timer_start - called when the timer is started
48 * @timer: pointer to struct timer_list
49 * @expires: the timers expiry time
50 */
51TRACE_EVENT(timer_start,
52
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070053 TP_PROTO(struct timer_list *timer,
54 unsigned long expires,
Thomas Gleixner0eeda712015-05-26 22:50:29 +000055 unsigned int flags),
Xiao Guangrong2b022e32009-08-10 10:48:59 +080056
Thomas Gleixner0eeda712015-05-26 22:50:29 +000057 TP_ARGS(timer, expires, flags),
Xiao Guangrong2b022e32009-08-10 10:48:59 +080058
59 TP_STRUCT__entry(
60 __field( void *, timer )
61 __field( void *, function )
62 __field( unsigned long, expires )
63 __field( unsigned long, now )
Thomas Gleixner0eeda712015-05-26 22:50:29 +000064 __field( unsigned int, flags )
Xiao Guangrong2b022e32009-08-10 10:48:59 +080065 ),
66
67 TP_fast_assign(
68 __entry->timer = timer;
69 __entry->function = timer->function;
70 __entry->expires = expires;
71 __entry->now = jiffies;
Thomas Gleixner0eeda712015-05-26 22:50:29 +000072 __entry->flags = flags;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080073 ),
74
Thomas Gleixner8a58a342017-02-10 16:41:15 +010075 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
Xiao Guangrong2b022e32009-08-10 10:48:59 +080076 __entry->timer, __entry->function, __entry->expires,
Thomas Gleixner8a58a342017-02-10 16:41:15 +010077 (long)__entry->expires - __entry->now,
78 __entry->flags & TIMER_CPUMASK,
79 __entry->flags >> TIMER_ARRAYSHIFT,
80 decode_timer_flags(__entry->flags & TIMER_TRACE_FLAGMASK))
Xiao Guangrong2b022e32009-08-10 10:48:59 +080081);
82
83/**
84 * timer_expire_entry - called immediately before the timer callback
85 * @timer: pointer to struct timer_list
86 *
87 * Allows to determine the timer latency.
88 */
89TRACE_EVENT(timer_expire_entry,
90
91 TP_PROTO(struct timer_list *timer),
92
93 TP_ARGS(timer),
94
95 TP_STRUCT__entry(
96 __field( void *, timer )
97 __field( unsigned long, now )
Arjan van de Venede1b422010-08-18 15:33:13 -070098 __field( void *, function)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080099 ),
100
101 TP_fast_assign(
102 __entry->timer = timer;
103 __entry->now = jiffies;
Arjan van de Venede1b422010-08-18 15:33:13 -0700104 __entry->function = timer->function;
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800105 ),
106
Arjan van de Venede1b422010-08-18 15:33:13 -0700107 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800108);
109
110/**
111 * timer_expire_exit - called immediately after the timer callback returns
112 * @timer: pointer to struct timer_list
113 *
114 * When used in combination with the timer_expire_entry tracepoint we can
115 * determine the runtime of the timer callback function.
116 *
117 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
118 * be invalid. We solely track the pointer.
119 */
Li Zefan363d0f62010-05-24 16:23:15 +0800120DEFINE_EVENT(timer_class, timer_expire_exit,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800121
122 TP_PROTO(struct timer_list *timer),
123
Li Zefan363d0f62010-05-24 16:23:15 +0800124 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800125);
126
127/**
128 * timer_cancel - called when the timer is canceled
129 * @timer: pointer to struct timer_list
130 */
Li Zefan363d0f62010-05-24 16:23:15 +0800131DEFINE_EVENT(timer_class, timer_cancel,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800132
133 TP_PROTO(struct timer_list *timer),
134
Li Zefan363d0f62010-05-24 16:23:15 +0800135 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800136);
137
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800138/**
139 * hrtimer_init - called when the hrtimer is initialized
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900140 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800141 * @clockid: the hrtimers clock
142 * @mode: the hrtimers mode
143 */
144TRACE_EVENT(hrtimer_init,
145
Ingo Molnar434a83c2009-10-15 11:50:39 +0200146 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800147 enum hrtimer_mode mode),
148
Ingo Molnar434a83c2009-10-15 11:50:39 +0200149 TP_ARGS(hrtimer, clockid, mode),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800150
151 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200152 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800153 __field( clockid_t, clockid )
154 __field( enum hrtimer_mode, mode )
155 ),
156
157 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200158 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800159 __entry->clockid = clockid;
160 __entry->mode = mode;
161 ),
162
Ingo Molnar434a83c2009-10-15 11:50:39 +0200163 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800164 __entry->clockid == CLOCK_REALTIME ?
165 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
166 __entry->mode == HRTIMER_MODE_ABS ?
167 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
168);
169
170/**
171 * hrtimer_start - called when the hrtimer is started
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900172 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800173 */
174TRACE_EVENT(hrtimer_start,
175
Ingo Molnar434a83c2009-10-15 11:50:39 +0200176 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800177
Ingo Molnar434a83c2009-10-15 11:50:39 +0200178 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800179
180 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200181 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800182 __field( void *, function )
183 __field( s64, expires )
184 __field( s64, softexpires )
185 ),
186
187 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200188 __entry->hrtimer = hrtimer;
189 __entry->function = hrtimer->function;
Thomas Gleixner2456e852016-12-25 11:38:40 +0100190 __entry->expires = hrtimer_get_expires(hrtimer);
191 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800192 ),
193
Ingo Molnar434a83c2009-10-15 11:50:39 +0200194 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
195 __entry->hrtimer, __entry->function,
Thomas Gleixner2456e852016-12-25 11:38:40 +0100196 (unsigned long long) __entry->expires,
197 (unsigned long long) __entry->softexpires)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800198);
199
200/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900201 * hrtimer_expire_entry - called immediately before the hrtimer callback
202 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800203 * @now: pointer to variable which contains current time of the
204 * timers base.
205 *
206 * Allows to determine the timer latency.
207 */
208TRACE_EVENT(hrtimer_expire_entry,
209
Ingo Molnar434a83c2009-10-15 11:50:39 +0200210 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800211
Ingo Molnar434a83c2009-10-15 11:50:39 +0200212 TP_ARGS(hrtimer, now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800213
214 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200215 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800216 __field( s64, now )
Arjan van de Venede1b422010-08-18 15:33:13 -0700217 __field( void *, function)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800218 ),
219
220 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200221 __entry->hrtimer = hrtimer;
Thomas Gleixner2456e852016-12-25 11:38:40 +0100222 __entry->now = *now;
Arjan van de Venede1b422010-08-18 15:33:13 -0700223 __entry->function = hrtimer->function;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800224 ),
225
Arjan van de Venede1b422010-08-18 15:33:13 -0700226 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
Thomas Gleixner2456e852016-12-25 11:38:40 +0100227 (unsigned long long) __entry->now)
228);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800229
Li Zefan363d0f62010-05-24 16:23:15 +0800230DECLARE_EVENT_CLASS(hrtimer_class,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800231
Ingo Molnar434a83c2009-10-15 11:50:39 +0200232 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800233
Ingo Molnar434a83c2009-10-15 11:50:39 +0200234 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800235
236 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200237 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800238 ),
239
240 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200241 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800242 ),
243
Ingo Molnar434a83c2009-10-15 11:50:39 +0200244 TP_printk("hrtimer=%p", __entry->hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800245);
246
247/**
Li Zefan363d0f62010-05-24 16:23:15 +0800248 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900249 * @hrtimer: pointer to struct hrtimer
Li Zefan363d0f62010-05-24 16:23:15 +0800250 *
251 * When used in combination with the hrtimer_expire_entry tracepoint we can
252 * determine the runtime of the callback function.
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800253 */
Li Zefan363d0f62010-05-24 16:23:15 +0800254DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800255
Ingo Molnar434a83c2009-10-15 11:50:39 +0200256 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800257
Li Zefan363d0f62010-05-24 16:23:15 +0800258 TP_ARGS(hrtimer)
259);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800260
Li Zefan363d0f62010-05-24 16:23:15 +0800261/**
262 * hrtimer_cancel - called when the hrtimer is canceled
263 * @hrtimer: pointer to struct hrtimer
264 */
265DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800266
Li Zefan363d0f62010-05-24 16:23:15 +0800267 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800268
Li Zefan363d0f62010-05-24 16:23:15 +0800269 TP_ARGS(hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800270);
271
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800272/**
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
278 */
279TRACE_EVENT(itimer_state,
280
281 TP_PROTO(int which, const struct itimerval *const value,
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100282 unsigned long long expires),
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800283
284 TP_ARGS(which, value, expires),
285
286 TP_STRUCT__entry(
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100287 __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 )
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800293 ),
294
295 TP_fast_assign(
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;
302 ),
303
Thomas Gleixnere9c0748b2009-12-10 13:23:19 +0100304 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100305 __entry->which, __entry->expires,
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800306 __entry->value_sec, __entry->value_usec,
307 __entry->interval_sec, __entry->interval_usec)
308);
309
310/**
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
315 */
316TRACE_EVENT(itimer_expire,
317
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100318 TP_PROTO(int which, struct pid *pid, unsigned long long now),
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800319
320 TP_ARGS(which, pid, now),
321
322 TP_STRUCT__entry(
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100323 __field( int , which )
324 __field( pid_t, pid )
325 __field( unsigned long long, now )
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800326 ),
327
328 TP_fast_assign(
329 __entry->which = which;
330 __entry->now = now;
331 __entry->pid = pid_nr(pid);
332 ),
333
Thomas Gleixnere9c0748b2009-12-10 13:23:19 +0100334 TP_printk("which=%d pid=%d now=%llu", __entry->which,
Frederic Weisbecker858cf3a2017-01-31 04:09:35 +0100335 (int) __entry->pid, __entry->now)
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800336);
337
Frederic Weisbecker2c82d1be2013-04-20 17:35:50 +0200338#ifdef CONFIG_NO_HZ_COMMON
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100339
340#define TICK_DEP_NAMES \
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400341 tick_dep_mask_name(NONE) \
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100342 tick_dep_name(POSIX_TIMER) \
343 tick_dep_name(PERF_EVENTS) \
344 tick_dep_name(SCHED) \
345 tick_dep_name_end(CLOCK_UNSTABLE)
346
347#undef tick_dep_name
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400348#undef tick_dep_mask_name
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100349#undef tick_dep_name_end
350
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400351/* 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);
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100358
359TICK_DEP_NAMES
360
361#undef tick_dep_name
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400362#undef tick_dep_mask_name
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100363#undef tick_dep_name_end
364
365#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400366#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100367#define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
368
369#define show_tick_dep_name(val) \
370 __print_symbolic(val, TICK_DEP_NAMES)
371
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200372TRACE_EVENT(tick_stop,
373
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100374 TP_PROTO(int success, int dependency),
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200375
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100376 TP_ARGS(success, dependency),
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200377
378 TP_STRUCT__entry(
379 __field( int , success )
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100380 __field( int , dependency )
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200381 ),
382
383 TP_fast_assign(
384 __entry->success = success;
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100385 __entry->dependency = dependency;
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200386 ),
387
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100388 TP_printk("success=%d dependency=%s", __entry->success, \
389 show_tick_dep_name(__entry->dependency))
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200390);
391#endif
392
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800393#endif /* _TRACE_TIMER_H */
394
395/* This part must be outside protection */
396#include <trace/define_trace.h>