blob: 1448637616d648475d5ccd28945df6fce617bca0 [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
39/**
Xiao Guangrong2b022e32009-08-10 10:48:59 +080040 * timer_start - called when the timer is started
41 * @timer: pointer to struct timer_list
42 * @expires: the timers expiry time
43 */
44TRACE_EVENT(timer_start,
45
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070046 TP_PROTO(struct timer_list *timer,
47 unsigned long expires,
Thomas Gleixner0eeda712015-05-26 22:50:29 +000048 unsigned int flags),
Xiao Guangrong2b022e32009-08-10 10:48:59 +080049
Thomas Gleixner0eeda712015-05-26 22:50:29 +000050 TP_ARGS(timer, expires, flags),
Xiao Guangrong2b022e32009-08-10 10:48:59 +080051
52 TP_STRUCT__entry(
53 __field( void *, timer )
54 __field( void *, function )
55 __field( unsigned long, expires )
56 __field( unsigned long, now )
Thomas Gleixner0eeda712015-05-26 22:50:29 +000057 __field( unsigned int, flags )
Xiao Guangrong2b022e32009-08-10 10:48:59 +080058 ),
59
60 TP_fast_assign(
61 __entry->timer = timer;
62 __entry->function = timer->function;
63 __entry->expires = expires;
64 __entry->now = jiffies;
Thomas Gleixner0eeda712015-05-26 22:50:29 +000065 __entry->flags = flags;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080066 ),
67
Thomas Gleixner0eeda712015-05-26 22:50:29 +000068 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] flags=0x%08x",
Xiao Guangrong2b022e32009-08-10 10:48:59 +080069 __entry->timer, __entry->function, __entry->expires,
Thomas Gleixner0eeda712015-05-26 22:50:29 +000070 (long)__entry->expires - __entry->now, __entry->flags)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080071);
72
73/**
74 * timer_expire_entry - called immediately before the timer callback
75 * @timer: pointer to struct timer_list
76 *
77 * Allows to determine the timer latency.
78 */
79TRACE_EVENT(timer_expire_entry,
80
81 TP_PROTO(struct timer_list *timer),
82
83 TP_ARGS(timer),
84
85 TP_STRUCT__entry(
86 __field( void *, timer )
87 __field( unsigned long, now )
Arjan van de Venede1b422010-08-18 15:33:13 -070088 __field( void *, function)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080089 ),
90
91 TP_fast_assign(
92 __entry->timer = timer;
93 __entry->now = jiffies;
Arjan van de Venede1b422010-08-18 15:33:13 -070094 __entry->function = timer->function;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080095 ),
96
Arjan van de Venede1b422010-08-18 15:33:13 -070097 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080098);
99
100/**
101 * timer_expire_exit - called immediately after the timer callback returns
102 * @timer: pointer to struct timer_list
103 *
104 * When used in combination with the timer_expire_entry tracepoint we can
105 * determine the runtime of the timer callback function.
106 *
107 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
108 * be invalid. We solely track the pointer.
109 */
Li Zefan363d0f62010-05-24 16:23:15 +0800110DEFINE_EVENT(timer_class, timer_expire_exit,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800111
112 TP_PROTO(struct timer_list *timer),
113
Li Zefan363d0f62010-05-24 16:23:15 +0800114 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800115);
116
117/**
118 * timer_cancel - called when the timer is canceled
119 * @timer: pointer to struct timer_list
120 */
Li Zefan363d0f62010-05-24 16:23:15 +0800121DEFINE_EVENT(timer_class, timer_cancel,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800122
123 TP_PROTO(struct timer_list *timer),
124
Li Zefan363d0f62010-05-24 16:23:15 +0800125 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800126);
127
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800128/**
129 * hrtimer_init - called when the hrtimer is initialized
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900130 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800131 * @clockid: the hrtimers clock
132 * @mode: the hrtimers mode
133 */
134TRACE_EVENT(hrtimer_init,
135
Ingo Molnar434a83c2009-10-15 11:50:39 +0200136 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800137 enum hrtimer_mode mode),
138
Ingo Molnar434a83c2009-10-15 11:50:39 +0200139 TP_ARGS(hrtimer, clockid, mode),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800140
141 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200142 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800143 __field( clockid_t, clockid )
144 __field( enum hrtimer_mode, mode )
145 ),
146
147 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200148 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800149 __entry->clockid = clockid;
150 __entry->mode = mode;
151 ),
152
Ingo Molnar434a83c2009-10-15 11:50:39 +0200153 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800154 __entry->clockid == CLOCK_REALTIME ?
155 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
156 __entry->mode == HRTIMER_MODE_ABS ?
157 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
158);
159
160/**
161 * hrtimer_start - called when the hrtimer is started
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900162 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800163 */
164TRACE_EVENT(hrtimer_start,
165
Ingo Molnar434a83c2009-10-15 11:50:39 +0200166 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800167
Ingo Molnar434a83c2009-10-15 11:50:39 +0200168 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800169
170 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200171 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800172 __field( void *, function )
173 __field( s64, expires )
174 __field( s64, softexpires )
175 ),
176
177 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200178 __entry->hrtimer = hrtimer;
179 __entry->function = hrtimer->function;
Thomas Gleixner2456e852016-12-25 11:38:40 +0100180 __entry->expires = hrtimer_get_expires(hrtimer);
181 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800182 ),
183
Ingo Molnar434a83c2009-10-15 11:50:39 +0200184 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
185 __entry->hrtimer, __entry->function,
Thomas Gleixner2456e852016-12-25 11:38:40 +0100186 (unsigned long long) __entry->expires,
187 (unsigned long long) __entry->softexpires)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800188);
189
190/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900191 * hrtimer_expire_entry - called immediately before the hrtimer callback
192 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800193 * @now: pointer to variable which contains current time of the
194 * timers base.
195 *
196 * Allows to determine the timer latency.
197 */
198TRACE_EVENT(hrtimer_expire_entry,
199
Ingo Molnar434a83c2009-10-15 11:50:39 +0200200 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800201
Ingo Molnar434a83c2009-10-15 11:50:39 +0200202 TP_ARGS(hrtimer, now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800203
204 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200205 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800206 __field( s64, now )
Arjan van de Venede1b422010-08-18 15:33:13 -0700207 __field( void *, function)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800208 ),
209
210 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200211 __entry->hrtimer = hrtimer;
Thomas Gleixner2456e852016-12-25 11:38:40 +0100212 __entry->now = *now;
Arjan van de Venede1b422010-08-18 15:33:13 -0700213 __entry->function = hrtimer->function;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800214 ),
215
Arjan van de Venede1b422010-08-18 15:33:13 -0700216 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
Thomas Gleixner2456e852016-12-25 11:38:40 +0100217 (unsigned long long) __entry->now)
218);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800219
Li Zefan363d0f62010-05-24 16:23:15 +0800220DECLARE_EVENT_CLASS(hrtimer_class,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800221
Ingo Molnar434a83c2009-10-15 11:50:39 +0200222 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800223
Ingo Molnar434a83c2009-10-15 11:50:39 +0200224 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800225
226 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200227 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800228 ),
229
230 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200231 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800232 ),
233
Ingo Molnar434a83c2009-10-15 11:50:39 +0200234 TP_printk("hrtimer=%p", __entry->hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800235);
236
237/**
Li Zefan363d0f62010-05-24 16:23:15 +0800238 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900239 * @hrtimer: pointer to struct hrtimer
Li Zefan363d0f62010-05-24 16:23:15 +0800240 *
241 * When used in combination with the hrtimer_expire_entry tracepoint we can
242 * determine the runtime of the callback function.
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800243 */
Li Zefan363d0f62010-05-24 16:23:15 +0800244DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800245
Ingo Molnar434a83c2009-10-15 11:50:39 +0200246 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800247
Li Zefan363d0f62010-05-24 16:23:15 +0800248 TP_ARGS(hrtimer)
249);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800250
Li Zefan363d0f62010-05-24 16:23:15 +0800251/**
252 * hrtimer_cancel - called when the hrtimer is canceled
253 * @hrtimer: pointer to struct hrtimer
254 */
255DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800256
Li Zefan363d0f62010-05-24 16:23:15 +0800257 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800258
Li Zefan363d0f62010-05-24 16:23:15 +0800259 TP_ARGS(hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800260);
261
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800262/**
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
268 */
269TRACE_EVENT(itimer_state,
270
271 TP_PROTO(int which, const struct itimerval *const value,
272 cputime_t expires),
273
274 TP_ARGS(which, value, expires),
275
276 TP_STRUCT__entry(
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 )
283 ),
284
285 TP_fast_assign(
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;
292 ),
293
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100294 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
295 __entry->which, (unsigned long long)__entry->expires,
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800296 __entry->value_sec, __entry->value_usec,
297 __entry->interval_sec, __entry->interval_usec)
298);
299
300/**
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
305 */
306TRACE_EVENT(itimer_expire,
307
308 TP_PROTO(int which, struct pid *pid, cputime_t now),
309
310 TP_ARGS(which, pid, now),
311
312 TP_STRUCT__entry(
313 __field( int , which )
314 __field( pid_t, pid )
315 __field( cputime_t, now )
316 ),
317
318 TP_fast_assign(
319 __entry->which = which;
320 __entry->now = now;
321 __entry->pid = pid_nr(pid);
322 ),
323
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100324 TP_printk("which=%d pid=%d now=%llu", __entry->which,
325 (int) __entry->pid, (unsigned long long)__entry->now)
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800326);
327
Frederic Weisbecker2c82d1be2013-04-20 17:35:50 +0200328#ifdef CONFIG_NO_HZ_COMMON
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100329
330#define TICK_DEP_NAMES \
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400331 tick_dep_mask_name(NONE) \
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100332 tick_dep_name(POSIX_TIMER) \
333 tick_dep_name(PERF_EVENTS) \
334 tick_dep_name(SCHED) \
335 tick_dep_name_end(CLOCK_UNSTABLE)
336
337#undef tick_dep_name
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400338#undef tick_dep_mask_name
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100339#undef tick_dep_name_end
340
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400341/* 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);
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100348
349TICK_DEP_NAMES
350
351#undef tick_dep_name
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400352#undef tick_dep_mask_name
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100353#undef tick_dep_name_end
354
355#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
Steven Rostedt (Red Hat)c87edb32016-08-05 12:41:52 -0400356#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100357#define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
358
359#define show_tick_dep_name(val) \
360 __print_symbolic(val, TICK_DEP_NAMES)
361
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200362TRACE_EVENT(tick_stop,
363
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100364 TP_PROTO(int success, int dependency),
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200365
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100366 TP_ARGS(success, dependency),
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200367
368 TP_STRUCT__entry(
369 __field( int , success )
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100370 __field( int , dependency )
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200371 ),
372
373 TP_fast_assign(
374 __entry->success = success;
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100375 __entry->dependency = dependency;
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200376 ),
377
Frederic Weisbeckere6e6cc22015-12-11 03:27:25 +0100378 TP_printk("success=%d dependency=%s", __entry->success, \
379 show_tick_dep_name(__entry->dependency))
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200380);
381#endif
382
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800383#endif /* _TRACE_TIMER_H */
384
385/* This part must be outside protection */
386#include <trace/define_trace.h>