blob: 68c2c2000f02bb639e1445245e1e460a18349f54 [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
46 TP_PROTO(struct timer_list *timer, unsigned long expires),
47
48 TP_ARGS(timer, expires),
49
50 TP_STRUCT__entry(
51 __field( void *, timer )
52 __field( void *, function )
53 __field( unsigned long, expires )
54 __field( unsigned long, now )
55 ),
56
57 TP_fast_assign(
58 __entry->timer = timer;
59 __entry->function = timer->function;
60 __entry->expires = expires;
61 __entry->now = jiffies;
62 ),
63
Ingo Molnar434a83c2009-10-15 11:50:39 +020064 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
Xiao Guangrong2b022e32009-08-10 10:48:59 +080065 __entry->timer, __entry->function, __entry->expires,
66 (long)__entry->expires - __entry->now)
67);
68
69/**
70 * timer_expire_entry - called immediately before the timer callback
71 * @timer: pointer to struct timer_list
72 *
73 * Allows to determine the timer latency.
74 */
75TRACE_EVENT(timer_expire_entry,
76
77 TP_PROTO(struct timer_list *timer),
78
79 TP_ARGS(timer),
80
81 TP_STRUCT__entry(
82 __field( void *, timer )
83 __field( unsigned long, now )
Arjan van de Venede1b422010-08-18 15:33:13 -070084 __field( void *, function)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080085 ),
86
87 TP_fast_assign(
88 __entry->timer = timer;
89 __entry->now = jiffies;
Arjan van de Venede1b422010-08-18 15:33:13 -070090 __entry->function = timer->function;
Xiao Guangrong2b022e32009-08-10 10:48:59 +080091 ),
92
Arjan van de Venede1b422010-08-18 15:33:13 -070093 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
Xiao Guangrong2b022e32009-08-10 10:48:59 +080094);
95
96/**
97 * timer_expire_exit - called immediately after the timer callback returns
98 * @timer: pointer to struct timer_list
99 *
100 * When used in combination with the timer_expire_entry tracepoint we can
101 * determine the runtime of the timer callback function.
102 *
103 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
104 * be invalid. We solely track the pointer.
105 */
Li Zefan363d0f62010-05-24 16:23:15 +0800106DEFINE_EVENT(timer_class, timer_expire_exit,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800107
108 TP_PROTO(struct timer_list *timer),
109
Li Zefan363d0f62010-05-24 16:23:15 +0800110 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800111);
112
113/**
114 * timer_cancel - called when the timer is canceled
115 * @timer: pointer to struct timer_list
116 */
Li Zefan363d0f62010-05-24 16:23:15 +0800117DEFINE_EVENT(timer_class, timer_cancel,
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800118
119 TP_PROTO(struct timer_list *timer),
120
Li Zefan363d0f62010-05-24 16:23:15 +0800121 TP_ARGS(timer)
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800122);
123
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800124/**
125 * hrtimer_init - called when the hrtimer is initialized
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900126 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800127 * @clockid: the hrtimers clock
128 * @mode: the hrtimers mode
129 */
130TRACE_EVENT(hrtimer_init,
131
Ingo Molnar434a83c2009-10-15 11:50:39 +0200132 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800133 enum hrtimer_mode mode),
134
Ingo Molnar434a83c2009-10-15 11:50:39 +0200135 TP_ARGS(hrtimer, clockid, mode),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800136
137 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200138 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800139 __field( clockid_t, clockid )
140 __field( enum hrtimer_mode, mode )
141 ),
142
143 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200144 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800145 __entry->clockid = clockid;
146 __entry->mode = mode;
147 ),
148
Ingo Molnar434a83c2009-10-15 11:50:39 +0200149 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800150 __entry->clockid == CLOCK_REALTIME ?
151 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
152 __entry->mode == HRTIMER_MODE_ABS ?
153 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
154);
155
156/**
157 * hrtimer_start - called when the hrtimer is started
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900158 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800159 */
160TRACE_EVENT(hrtimer_start,
161
Ingo Molnar434a83c2009-10-15 11:50:39 +0200162 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800163
Ingo Molnar434a83c2009-10-15 11:50:39 +0200164 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800165
166 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200167 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800168 __field( void *, function )
169 __field( s64, expires )
170 __field( s64, softexpires )
171 ),
172
173 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200174 __entry->hrtimer = hrtimer;
175 __entry->function = hrtimer->function;
176 __entry->expires = hrtimer_get_expires(hrtimer).tv64;
177 __entry->softexpires = hrtimer_get_softexpires(hrtimer).tv64;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800178 ),
179
Ingo Molnar434a83c2009-10-15 11:50:39 +0200180 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
181 __entry->hrtimer, __entry->function,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800182 (unsigned long long)ktime_to_ns((ktime_t) {
183 .tv64 = __entry->expires }),
184 (unsigned long long)ktime_to_ns((ktime_t) {
185 .tv64 = __entry->softexpires }))
186);
187
188/**
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900189 * hrtimer_expire_entry - called immediately before the hrtimer callback
190 * @hrtimer: pointer to struct hrtimer
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800191 * @now: pointer to variable which contains current time of the
192 * timers base.
193 *
194 * Allows to determine the timer latency.
195 */
196TRACE_EVENT(hrtimer_expire_entry,
197
Ingo Molnar434a83c2009-10-15 11:50:39 +0200198 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800199
Ingo Molnar434a83c2009-10-15 11:50:39 +0200200 TP_ARGS(hrtimer, now),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800201
202 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200203 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800204 __field( s64, now )
Arjan van de Venede1b422010-08-18 15:33:13 -0700205 __field( void *, function)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800206 ),
207
208 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200209 __entry->hrtimer = hrtimer;
210 __entry->now = now->tv64;
Arjan van de Venede1b422010-08-18 15:33:13 -0700211 __entry->function = hrtimer->function;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800212 ),
213
Arjan van de Venede1b422010-08-18 15:33:13 -0700214 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
Ingo Molnar434a83c2009-10-15 11:50:39 +0200215 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800216 );
217
Li Zefan363d0f62010-05-24 16:23:15 +0800218DECLARE_EVENT_CLASS(hrtimer_class,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800219
Ingo Molnar434a83c2009-10-15 11:50:39 +0200220 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800221
Ingo Molnar434a83c2009-10-15 11:50:39 +0200222 TP_ARGS(hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800223
224 TP_STRUCT__entry(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200225 __field( void *, hrtimer )
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800226 ),
227
228 TP_fast_assign(
Ingo Molnar434a83c2009-10-15 11:50:39 +0200229 __entry->hrtimer = hrtimer;
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800230 ),
231
Ingo Molnar434a83c2009-10-15 11:50:39 +0200232 TP_printk("hrtimer=%p", __entry->hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800233);
234
235/**
Li Zefan363d0f62010-05-24 16:23:15 +0800236 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
Masanari Iidacf2fbdd2013-03-16 20:53:05 +0900237 * @hrtimer: pointer to struct hrtimer
Li Zefan363d0f62010-05-24 16:23:15 +0800238 *
239 * When used in combination with the hrtimer_expire_entry tracepoint we can
240 * determine the runtime of the callback function.
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800241 */
Li Zefan363d0f62010-05-24 16:23:15 +0800242DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800243
Ingo Molnar434a83c2009-10-15 11:50:39 +0200244 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800245
Li Zefan363d0f62010-05-24 16:23:15 +0800246 TP_ARGS(hrtimer)
247);
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800248
Li Zefan363d0f62010-05-24 16:23:15 +0800249/**
250 * hrtimer_cancel - called when the hrtimer is canceled
251 * @hrtimer: pointer to struct hrtimer
252 */
253DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800254
Li Zefan363d0f62010-05-24 16:23:15 +0800255 TP_PROTO(struct hrtimer *hrtimer),
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800256
Li Zefan363d0f62010-05-24 16:23:15 +0800257 TP_ARGS(hrtimer)
Xiao Guangrongc6a2a172009-08-10 10:51:23 +0800258);
259
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800260/**
261 * itimer_state - called when itimer is started or canceled
262 * @which: name of the interval timer
263 * @value: the itimers value, itimer is canceled if value->it_value is
264 * zero, otherwise it is started
265 * @expires: the itimers expiry time
266 */
267TRACE_EVENT(itimer_state,
268
269 TP_PROTO(int which, const struct itimerval *const value,
270 cputime_t expires),
271
272 TP_ARGS(which, value, expires),
273
274 TP_STRUCT__entry(
275 __field( int, which )
276 __field( cputime_t, expires )
277 __field( long, value_sec )
278 __field( long, value_usec )
279 __field( long, interval_sec )
280 __field( long, interval_usec )
281 ),
282
283 TP_fast_assign(
284 __entry->which = which;
285 __entry->expires = expires;
286 __entry->value_sec = value->it_value.tv_sec;
287 __entry->value_usec = value->it_value.tv_usec;
288 __entry->interval_sec = value->it_interval.tv_sec;
289 __entry->interval_usec = value->it_interval.tv_usec;
290 ),
291
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100292 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
293 __entry->which, (unsigned long long)__entry->expires,
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800294 __entry->value_sec, __entry->value_usec,
295 __entry->interval_sec, __entry->interval_usec)
296);
297
298/**
299 * itimer_expire - called when itimer expires
300 * @which: type of the interval timer
301 * @pid: pid of the process which owns the timer
302 * @now: current time, used to calculate the latency of itimer
303 */
304TRACE_EVENT(itimer_expire,
305
306 TP_PROTO(int which, struct pid *pid, cputime_t now),
307
308 TP_ARGS(which, pid, now),
309
310 TP_STRUCT__entry(
311 __field( int , which )
312 __field( pid_t, pid )
313 __field( cputime_t, now )
314 ),
315
316 TP_fast_assign(
317 __entry->which = which;
318 __entry->now = now;
319 __entry->pid = pid_nr(pid);
320 ),
321
Thomas Gleixnere9c07482009-12-10 13:23:19 +0100322 TP_printk("which=%d pid=%d now=%llu", __entry->which,
323 (int) __entry->pid, (unsigned long long)__entry->now)
Xiao Guangrong3f0a5252009-08-10 10:52:30 +0800324);
325
Frederic Weisbecker2c82d1be2013-04-20 17:35:50 +0200326#ifdef CONFIG_NO_HZ_COMMON
Frederic Weisbeckercb41a292013-04-20 17:35:50 +0200327TRACE_EVENT(tick_stop,
328
329 TP_PROTO(int success, char *error_msg),
330
331 TP_ARGS(success, error_msg),
332
333 TP_STRUCT__entry(
334 __field( int , success )
335 __string( msg, error_msg )
336 ),
337
338 TP_fast_assign(
339 __entry->success = success;
340 __assign_str(msg, error_msg);
341 ),
342
343 TP_printk("success=%s msg=%s", __entry->success ? "yes" : "no", __get_str(msg))
344);
345#endif
346
Xiao Guangrong2b022e32009-08-10 10:48:59 +0800347#endif /* _TRACE_TIMER_H */
348
349/* This part must be outside protection */
350#include <trace/define_trace.h>