Merge remote-tracking branch 'selinux/next'
[deliverable/linux.git] / include / trace / events / timer.h
CommitLineData
2b022e3d
XG
1#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>
c6a2a177 8#include <linux/hrtimer.h>
2b022e3d
XG
9#include <linux/timer.h>
10
363d0f64 11DECLARE_EVENT_CLASS(timer_class,
2b022e3d
XG
12
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
434a83c3 25 TP_printk("timer=%p", __entry->timer)
2b022e3d
XG
26);
27
363d0f64
LZ
28/**
29 * 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
2b022e3d
XG
39/**
40 * 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
4e413e85
BJS
46 TP_PROTO(struct timer_list *timer,
47 unsigned long expires,
0eeda71b 48 unsigned int flags),
2b022e3d 49
0eeda71b 50 TP_ARGS(timer, expires, flags),
2b022e3d
XG
51
52 TP_STRUCT__entry(
53 __field( void *, timer )
54 __field( void *, function )
55 __field( unsigned long, expires )
56 __field( unsigned long, now )
0eeda71b 57 __field( unsigned int, flags )
2b022e3d
XG
58 ),
59
60 TP_fast_assign(
61 __entry->timer = timer;
62 __entry->function = timer->function;
63 __entry->expires = expires;
64 __entry->now = jiffies;
0eeda71b 65 __entry->flags = flags;
2b022e3d
XG
66 ),
67
0eeda71b 68 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] flags=0x%08x",
2b022e3d 69 __entry->timer, __entry->function, __entry->expires,
0eeda71b 70 (long)__entry->expires - __entry->now, __entry->flags)
2b022e3d
XG
71);
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 )
ede1b429 88 __field( void *, function)
2b022e3d
XG
89 ),
90
91 TP_fast_assign(
92 __entry->timer = timer;
93 __entry->now = jiffies;
ede1b429 94 __entry->function = timer->function;
2b022e3d
XG
95 ),
96
ede1b429 97 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
2b022e3d
XG
98);
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 */
363d0f64 110DEFINE_EVENT(timer_class, timer_expire_exit,
2b022e3d
XG
111
112 TP_PROTO(struct timer_list *timer),
113
363d0f64 114 TP_ARGS(timer)
2b022e3d
XG
115);
116
117/**
118 * timer_cancel - called when the timer is canceled
119 * @timer: pointer to struct timer_list
120 */
363d0f64 121DEFINE_EVENT(timer_class, timer_cancel,
2b022e3d
XG
122
123 TP_PROTO(struct timer_list *timer),
124
363d0f64 125 TP_ARGS(timer)
2b022e3d
XG
126);
127
c6a2a177
XG
128/**
129 * hrtimer_init - called when the hrtimer is initialized
cf2fbdd2 130 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
131 * @clockid: the hrtimers clock
132 * @mode: the hrtimers mode
133 */
134TRACE_EVENT(hrtimer_init,
135
434a83c3 136 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
c6a2a177
XG
137 enum hrtimer_mode mode),
138
434a83c3 139 TP_ARGS(hrtimer, clockid, mode),
c6a2a177
XG
140
141 TP_STRUCT__entry(
434a83c3 142 __field( void *, hrtimer )
c6a2a177
XG
143 __field( clockid_t, clockid )
144 __field( enum hrtimer_mode, mode )
145 ),
146
147 TP_fast_assign(
434a83c3 148 __entry->hrtimer = hrtimer;
c6a2a177
XG
149 __entry->clockid = clockid;
150 __entry->mode = mode;
151 ),
152
434a83c3 153 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
c6a2a177
XG
154 __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
cf2fbdd2 162 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
163 */
164TRACE_EVENT(hrtimer_start,
165
434a83c3 166 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 167
434a83c3 168 TP_ARGS(hrtimer),
c6a2a177
XG
169
170 TP_STRUCT__entry(
434a83c3 171 __field( void *, hrtimer )
c6a2a177
XG
172 __field( void *, function )
173 __field( s64, expires )
174 __field( s64, softexpires )
175 ),
176
177 TP_fast_assign(
434a83c3
IM
178 __entry->hrtimer = hrtimer;
179 __entry->function = hrtimer->function;
180 __entry->expires = hrtimer_get_expires(hrtimer).tv64;
181 __entry->softexpires = hrtimer_get_softexpires(hrtimer).tv64;
c6a2a177
XG
182 ),
183
434a83c3
IM
184 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
185 __entry->hrtimer, __entry->function,
c6a2a177
XG
186 (unsigned long long)ktime_to_ns((ktime_t) {
187 .tv64 = __entry->expires }),
188 (unsigned long long)ktime_to_ns((ktime_t) {
189 .tv64 = __entry->softexpires }))
190);
191
192/**
cf2fbdd2
MI
193 * hrtimer_expire_entry - called immediately before the hrtimer callback
194 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
195 * @now: pointer to variable which contains current time of the
196 * timers base.
197 *
198 * Allows to determine the timer latency.
199 */
200TRACE_EVENT(hrtimer_expire_entry,
201
434a83c3 202 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
c6a2a177 203
434a83c3 204 TP_ARGS(hrtimer, now),
c6a2a177
XG
205
206 TP_STRUCT__entry(
434a83c3 207 __field( void *, hrtimer )
c6a2a177 208 __field( s64, now )
ede1b429 209 __field( void *, function)
c6a2a177
XG
210 ),
211
212 TP_fast_assign(
434a83c3
IM
213 __entry->hrtimer = hrtimer;
214 __entry->now = now->tv64;
ede1b429 215 __entry->function = hrtimer->function;
c6a2a177
XG
216 ),
217
ede1b429 218 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
434a83c3 219 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
c6a2a177
XG
220 );
221
363d0f64 222DECLARE_EVENT_CLASS(hrtimer_class,
c6a2a177 223
434a83c3 224 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 225
434a83c3 226 TP_ARGS(hrtimer),
c6a2a177
XG
227
228 TP_STRUCT__entry(
434a83c3 229 __field( void *, hrtimer )
c6a2a177
XG
230 ),
231
232 TP_fast_assign(
434a83c3 233 __entry->hrtimer = hrtimer;
c6a2a177
XG
234 ),
235
434a83c3 236 TP_printk("hrtimer=%p", __entry->hrtimer)
c6a2a177
XG
237);
238
239/**
363d0f64 240 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
cf2fbdd2 241 * @hrtimer: pointer to struct hrtimer
363d0f64
LZ
242 *
243 * When used in combination with the hrtimer_expire_entry tracepoint we can
244 * determine the runtime of the callback function.
c6a2a177 245 */
363d0f64 246DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
c6a2a177 247
434a83c3 248 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 249
363d0f64
LZ
250 TP_ARGS(hrtimer)
251);
c6a2a177 252
363d0f64
LZ
253/**
254 * hrtimer_cancel - called when the hrtimer is canceled
255 * @hrtimer: pointer to struct hrtimer
256 */
257DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
c6a2a177 258
363d0f64 259 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 260
363d0f64 261 TP_ARGS(hrtimer)
c6a2a177
XG
262);
263
3f0a525e
XG
264/**
265 * itimer_state - called when itimer is started or canceled
266 * @which: name of the interval timer
267 * @value: the itimers value, itimer is canceled if value->it_value is
268 * zero, otherwise it is started
269 * @expires: the itimers expiry time
270 */
271TRACE_EVENT(itimer_state,
272
273 TP_PROTO(int which, const struct itimerval *const value,
274 cputime_t expires),
275
276 TP_ARGS(which, value, expires),
277
278 TP_STRUCT__entry(
279 __field( int, which )
280 __field( cputime_t, expires )
281 __field( long, value_sec )
282 __field( long, value_usec )
283 __field( long, interval_sec )
284 __field( long, interval_usec )
285 ),
286
287 TP_fast_assign(
288 __entry->which = which;
289 __entry->expires = expires;
290 __entry->value_sec = value->it_value.tv_sec;
291 __entry->value_usec = value->it_value.tv_usec;
292 __entry->interval_sec = value->it_interval.tv_sec;
293 __entry->interval_usec = value->it_interval.tv_usec;
294 ),
295
e9c0748b
TG
296 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
297 __entry->which, (unsigned long long)__entry->expires,
3f0a525e
XG
298 __entry->value_sec, __entry->value_usec,
299 __entry->interval_sec, __entry->interval_usec)
300);
301
302/**
303 * itimer_expire - called when itimer expires
304 * @which: type of the interval timer
305 * @pid: pid of the process which owns the timer
306 * @now: current time, used to calculate the latency of itimer
307 */
308TRACE_EVENT(itimer_expire,
309
310 TP_PROTO(int which, struct pid *pid, cputime_t now),
311
312 TP_ARGS(which, pid, now),
313
314 TP_STRUCT__entry(
315 __field( int , which )
316 __field( pid_t, pid )
317 __field( cputime_t, now )
318 ),
319
320 TP_fast_assign(
321 __entry->which = which;
322 __entry->now = now;
323 __entry->pid = pid_nr(pid);
324 ),
325
e9c0748b
TG
326 TP_printk("which=%d pid=%d now=%llu", __entry->which,
327 (int) __entry->pid, (unsigned long long)__entry->now)
3f0a525e
XG
328);
329
2c82d1be 330#ifdef CONFIG_NO_HZ_COMMON
e6e6cc22
FW
331
332#define TICK_DEP_NAMES \
c87edb36 333 tick_dep_mask_name(NONE) \
e6e6cc22
FW
334 tick_dep_name(POSIX_TIMER) \
335 tick_dep_name(PERF_EVENTS) \
336 tick_dep_name(SCHED) \
337 tick_dep_name_end(CLOCK_UNSTABLE)
338
339#undef tick_dep_name
c87edb36 340#undef tick_dep_mask_name
e6e6cc22
FW
341#undef tick_dep_name_end
342
c87edb36
SRRH
343/* The MASK will convert to their bits and they need to be processed too */
344#define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
345 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
346#define tick_dep_name_end(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
347 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
348/* NONE only has a mask defined for it */
349#define tick_dep_mask_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
e6e6cc22
FW
350
351TICK_DEP_NAMES
352
353#undef tick_dep_name
c87edb36 354#undef tick_dep_mask_name
e6e6cc22
FW
355#undef tick_dep_name_end
356
357#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
c87edb36 358#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
e6e6cc22
FW
359#define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
360
361#define show_tick_dep_name(val) \
362 __print_symbolic(val, TICK_DEP_NAMES)
363
cb41a290
FW
364TRACE_EVENT(tick_stop,
365
e6e6cc22 366 TP_PROTO(int success, int dependency),
cb41a290 367
e6e6cc22 368 TP_ARGS(success, dependency),
cb41a290
FW
369
370 TP_STRUCT__entry(
371 __field( int , success )
e6e6cc22 372 __field( int , dependency )
cb41a290
FW
373 ),
374
375 TP_fast_assign(
376 __entry->success = success;
e6e6cc22 377 __entry->dependency = dependency;
cb41a290
FW
378 ),
379
e6e6cc22
FW
380 TP_printk("success=%d dependency=%s", __entry->success, \
381 show_tick_dep_name(__entry->dependency))
cb41a290
FW
382);
383#endif
384
2b022e3d
XG
385#endif /* _TRACE_TIMER_H */
386
387/* This part must be outside protection */
388#include <trace/define_trace.h>
This page took 0.336145 seconds and 5 git commands to generate.