blob: d7abef1fe6e010d5250d0994b1c65edd70b8b3ec [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,
48 unsigned int deferrable),
Xiao Guangrong2b022e32009-08-10 10:48:59 +080049
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070050 TP_ARGS(timer, expires, deferrable),
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 )
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070057 __field( unsigned int, deferrable )
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;
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070065 __entry->deferrable = deferrable;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080066 ),
67
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070068 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] defer=%c",
Xiao Guangrong2b022e32009-08-10 10:48:59 +080069 __entry->timer, __entry->function, __entry->expires,
Badhri Jagan Sridharan4e413e82015-05-07 16:20:34 -070070 (long)__entry->expires - __entry->now,
71 __entry->deferrable > 0 ? 'y':'n')
Xiao Guangrong2b022e32009-08-10 10:48:59 +080072);
73
74/**
75 * timer_expire_entry - called immediately before the timer callback
76 * @timer: pointer to struct timer_list
77 *
78 * Allows to determine the timer latency.
79 */
80TRACE_EVENT(timer_expire_entry,
81
82 TP_PROTO(struct timer_list *timer),
83
84 TP_ARGS(timer),
85
86 TP_STRUCT__entry(
87 __field( void *, timer )
88 __field( unsigned long, now )
Arjan van de Venede1b422010-08-18 15:33:13 -070089 __field( void *, function)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080090 ),
91
92 TP_fast_assign(
93 __entry->timer = timer;
94 __entry->now = jiffies;
Arjan van de Venede1b422010-08-18 15:33:13 -070095 __entry->function = timer->function;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080096 ),
97
Arjan van de Venede1b422010-08-18 15:33:13 -070098 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080099);
100
101/**
102 * timer_expire_exit - called immediately after the timer callback returns
103 * @timer: pointer to struct timer_list
104 *
105 * When used in combination with the timer_expire_entry tracepoint we can
106 * determine the runtime of the timer callback function.
107 *
108 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
109 * be invalid. We solely track the pointer.
110 */
Li Zefan363d0f62010-05-24 16:23:15 +0800111DEFINE_EVENT(timer_class, timer_expire_exit,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800112
113 TP_PROTO(struct timer_list *timer),
114
Li Zefan363d0f62010-05-24 16:23:15 +0800115 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800116);
117
118/**
119 * timer_cancel - called when the timer is canceled
120 * @timer: pointer to struct timer_list
121 */
Li Zefan363d0f62010-05-24 16:23:15 +0800122DEFINE_EVENT(timer_class, timer_cancel,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800123
124 TP_PROTO(struct timer_list *timer),
125
Li Zefan363d0f62010-05-24 16:23:15 +0800126 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800127);
128
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800129/**
130 * hrtimer_init - called when the hrtimer is initialized
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900131 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800132 * @clockid: the hrtimers clock
133 * @mode: the hrtimers mode
134 */
135TRACE_EVENT(hrtimer_init,
136
Ingo Molnar434a83c2009-10-15 11:50:39 +0200137 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800138 enum hrtimer_mode mode),
139
Ingo Molnar434a83c2009-10-15 11:50:39 +0200140 TP_ARGS(hrtimer, clockid, mode),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800141
142 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200143 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800144 __field( clockid_t, clockid )
145 __field( enum hrtimer_mode, mode )
146 ),
147
148 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200149 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800150 __entry->clockid = clockid;
151 __entry->mode = mode;
152 ),
153
Ingo Molnar434a83c2009-10-15 11:50:39 +0200154 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800155 __entry->clockid == CLOCK_REALTIME ?
156 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
157 __entry->mode == HRTIMER_MODE_ABS ?
158 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
159);
160
161/**
162 * hrtimer_start - called when the hrtimer is started
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900163 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800164 */
165TRACE_EVENT(hrtimer_start,
166
Ingo Molnar434a83c2009-10-15 11:50:39 +0200167 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800168
Ingo Molnar434a83c2009-10-15 11:50:39 +0200169 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800170
171 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200172 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800173 __field( void *, function )
174 __field( s64, expires )
175 __field( s64, softexpires )
176 ),
177
178 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200179 __entry->hrtimer = hrtimer;
180 __entry->function = hrtimer->function;
181 __entry->expires = hrtimer_get_expires(hrtimer).tv64;
182 __entry->softexpires = hrtimer_get_softexpires(hrtimer).tv64;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800183 ),
184
Ingo Molnar434a83c2009-10-15 11:50:39 +0200185 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
186 __entry->hrtimer, __entry->function,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800187 (unsigned long long)ktime_to_ns((ktime_t) {
188 .tv64 = __entry->expires }),
189 (unsigned long long)ktime_to_ns((ktime_t) {
190 .tv64 = __entry->softexpires }))
191);
192
193/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900194 * hrtimer_expire_entry - called immediately before the hrtimer callback
195 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800196 * @now: pointer to variable which contains current time of the
197 * timers base.
198 *
199 * Allows to determine the timer latency.
200 */
201TRACE_EVENT(hrtimer_expire_entry,
202
Ingo Molnar434a83c2009-10-15 11:50:39 +0200203 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800204
Ingo Molnar434a83c2009-10-15 11:50:39 +0200205 TP_ARGS(hrtimer, now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800206
207 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200208 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800209 __field( s64, now )
Arjan van de Venede1b422010-08-18 15:33:13 -0700210 __field( void *, function)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800211 ),
212
213 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200214 __entry->hrtimer = hrtimer;
215 __entry->now = now->tv64;
Arjan van de Venede1b422010-08-18 15:33:13 -0700216 __entry->function = hrtimer->function;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800217 ),
218
Arjan van de Venede1b422010-08-18 15:33:13 -0700219 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
Ingo Molnar434a83c2009-10-15 11:50:39 +0200220 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800221 );
222
Li Zefan363d0f62010-05-24 16:23:15 +0800223DECLARE_EVENT_CLASS(hrtimer_class,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800224
Ingo Molnar434a83c2009-10-15 11:50:39 +0200225 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800226
Ingo Molnar434a83c2009-10-15 11:50:39 +0200227 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800228
229 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200230 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800231 ),
232
233 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200234 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800235 ),
236
Ingo Molnar434a83c2009-10-15 11:50:39 +0200237 TP_printk("hrtimer=%p", __entry->hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800238);
239
240/**
Li Zefan363d0f62010-05-24 16:23:15 +0800241 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900242 * @hrtimer: pointer to struct hrtimer
Li Zefan363d0f62010-05-24 16:23:15 +0800243 *
244 * When used in combination with the hrtimer_expire_entry tracepoint we can
245 * determine the runtime of the callback function.
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800246 */
Li Zefan363d0f62010-05-24 16:23:15 +0800247DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800248
Ingo Molnar434a83c2009-10-15 11:50:39 +0200249 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800250
Li Zefan363d0f62010-05-24 16:23:15 +0800251 TP_ARGS(hrtimer)
252);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800253
Li Zefan363d0f62010-05-24 16:23:15 +0800254/**
255 * hrtimer_cancel - called when the hrtimer is canceled
256 * @hrtimer: pointer to struct hrtimer
257 */
258DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800259
Li Zefan363d0f62010-05-24 16:23:15 +0800260 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800261
Li Zefan363d0f62010-05-24 16:23:15 +0800262 TP_ARGS(hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800263);
264
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800265/**
266 * itimer_state - called when itimer is started or canceled
267 * @which: name of the interval timer
268 * @value: the itimers value, itimer is canceled if value->it_value is
269 * zero, otherwise it is started
270 * @expires: the itimers expiry time
271 */
272TRACE_EVENT(itimer_state,
273
274 TP_PROTO(int which, const struct itimerval *const value,
275 cputime_t expires),
276
277 TP_ARGS(which, value, expires),
278
279 TP_STRUCT__entry(
280 __field( int, which )
281 __field( cputime_t, expires )
282 __field( long, value_sec )
283 __field( long, value_usec )
284 __field( long, interval_sec )
285 __field( long, interval_usec )
286 ),
287
288 TP_fast_assign(
289 __entry->which = which;
290 __entry->expires = expires;
291 __entry->value_sec = value->it_value.tv_sec;
292 __entry->value_usec = value->it_value.tv_usec;
293 __entry->interval_sec = value->it_interval.tv_sec;
294 __entry->interval_usec = value->it_interval.tv_usec;
295 ),
296
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100297 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
298 __entry->which, (unsigned long long)__entry->expires,
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800299 __entry->value_sec, __entry->value_usec,
300 __entry->interval_sec, __entry->interval_usec)
301);
302
303/**
304 * itimer_expire - called when itimer expires
305 * @which: type of the interval timer
306 * @pid: pid of the process which owns the timer
307 * @now: current time, used to calculate the latency of itimer
308 */
309TRACE_EVENT(itimer_expire,
310
311 TP_PROTO(int which, struct pid *pid, cputime_t now),
312
313 TP_ARGS(which, pid, now),
314
315 TP_STRUCT__entry(
316 __field( int , which )
317 __field( pid_t, pid )
318 __field( cputime_t, now )
319 ),
320
321 TP_fast_assign(
322 __entry->which = which;
323 __entry->now = now;
324 __entry->pid = pid_nr(pid);
325 ),
326
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100327 TP_printk("which=%d pid=%d now=%llu", __entry->which,
328 (int) __entry->pid, (unsigned long long)__entry->now)
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800329);
330
Frederic Weisbecker2c82d1be2013-04-20 17:35:50 +0200331#ifdef CONFIG_NO_HZ_COMMON
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200332TRACE_EVENT(tick_stop,
333
334 TP_PROTO(int success, char *error_msg),
335
336 TP_ARGS(success, error_msg),
337
338 TP_STRUCT__entry(
339 __field( int , success )
340 __string( msg, error_msg )
341 ),
342
343 TP_fast_assign(
344 __entry->success = success;
345 __assign_str(msg, error_msg);
346 ),
347
348 TP_printk("success=%s msg=%s", __entry->success ? "yes" : "no", __get_str(msg))
349);
350#endif
351
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800352#endif /* _TRACE_TIMER_H */
353
354/* This part must be outside protection */
355#include <trace/define_trace.h>