]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/trace/events/timer.h
dax: Inline dax_pmd_insert_mapping() into the callsite
[mirror_ubuntu-bionic-kernel.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
8a58a34b
TG
39#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
2b022e3d
XG
46/**
47 * 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
4e413e85
BJS
53 TP_PROTO(struct timer_list *timer,
54 unsigned long expires,
0eeda71b 55 unsigned int flags),
2b022e3d 56
0eeda71b 57 TP_ARGS(timer, expires, flags),
2b022e3d
XG
58
59 TP_STRUCT__entry(
60 __field( void *, timer )
61 __field( void *, function )
62 __field( unsigned long, expires )
63 __field( unsigned long, now )
0eeda71b 64 __field( unsigned int, flags )
2b022e3d
XG
65 ),
66
67 TP_fast_assign(
68 __entry->timer = timer;
69 __entry->function = timer->function;
70 __entry->expires = expires;
71 __entry->now = jiffies;
0eeda71b 72 __entry->flags = flags;
2b022e3d
XG
73 ),
74
8a58a34b 75 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
2b022e3d 76 __entry->timer, __entry->function, __entry->expires,
8a58a34b
TG
77 (long)__entry->expires - __entry->now,
78 __entry->flags & TIMER_CPUMASK,
79 __entry->flags >> TIMER_ARRAYSHIFT,
80 decode_timer_flags(__entry->flags & TIMER_TRACE_FLAGMASK))
2b022e3d
XG
81);
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 )
ede1b429 98 __field( void *, function)
2b022e3d
XG
99 ),
100
101 TP_fast_assign(
102 __entry->timer = timer;
103 __entry->now = jiffies;
ede1b429 104 __entry->function = timer->function;
2b022e3d
XG
105 ),
106
ede1b429 107 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
2b022e3d
XG
108);
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 */
363d0f64 120DEFINE_EVENT(timer_class, timer_expire_exit,
2b022e3d
XG
121
122 TP_PROTO(struct timer_list *timer),
123
363d0f64 124 TP_ARGS(timer)
2b022e3d
XG
125);
126
127/**
128 * timer_cancel - called when the timer is canceled
129 * @timer: pointer to struct timer_list
130 */
363d0f64 131DEFINE_EVENT(timer_class, timer_cancel,
2b022e3d
XG
132
133 TP_PROTO(struct timer_list *timer),
134
363d0f64 135 TP_ARGS(timer)
2b022e3d
XG
136);
137
c6a2a177
XG
138/**
139 * hrtimer_init - called when the hrtimer is initialized
cf2fbdd2 140 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
141 * @clockid: the hrtimers clock
142 * @mode: the hrtimers mode
143 */
144TRACE_EVENT(hrtimer_init,
145
434a83c3 146 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
c6a2a177
XG
147 enum hrtimer_mode mode),
148
434a83c3 149 TP_ARGS(hrtimer, clockid, mode),
c6a2a177
XG
150
151 TP_STRUCT__entry(
434a83c3 152 __field( void *, hrtimer )
c6a2a177
XG
153 __field( clockid_t, clockid )
154 __field( enum hrtimer_mode, mode )
155 ),
156
157 TP_fast_assign(
434a83c3 158 __entry->hrtimer = hrtimer;
c6a2a177
XG
159 __entry->clockid = clockid;
160 __entry->mode = mode;
161 ),
162
434a83c3 163 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
c6a2a177
XG
164 __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
cf2fbdd2 172 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
173 */
174TRACE_EVENT(hrtimer_start,
175
434a83c3 176 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 177
434a83c3 178 TP_ARGS(hrtimer),
c6a2a177
XG
179
180 TP_STRUCT__entry(
434a83c3 181 __field( void *, hrtimer )
c6a2a177
XG
182 __field( void *, function )
183 __field( s64, expires )
184 __field( s64, softexpires )
185 ),
186
187 TP_fast_assign(
434a83c3
IM
188 __entry->hrtimer = hrtimer;
189 __entry->function = hrtimer->function;
2456e855
TG
190 __entry->expires = hrtimer_get_expires(hrtimer);
191 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
c6a2a177
XG
192 ),
193
434a83c3
IM
194 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
195 __entry->hrtimer, __entry->function,
2456e855
TG
196 (unsigned long long) __entry->expires,
197 (unsigned long long) __entry->softexpires)
c6a2a177
XG
198);
199
200/**
cf2fbdd2
MI
201 * hrtimer_expire_entry - called immediately before the hrtimer callback
202 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
203 * @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
434a83c3 210 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
c6a2a177 211
434a83c3 212 TP_ARGS(hrtimer, now),
c6a2a177
XG
213
214 TP_STRUCT__entry(
434a83c3 215 __field( void *, hrtimer )
c6a2a177 216 __field( s64, now )
ede1b429 217 __field( void *, function)
c6a2a177
XG
218 ),
219
220 TP_fast_assign(
434a83c3 221 __entry->hrtimer = hrtimer;
2456e855 222 __entry->now = *now;
ede1b429 223 __entry->function = hrtimer->function;
c6a2a177
XG
224 ),
225
ede1b429 226 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
2456e855
TG
227 (unsigned long long) __entry->now)
228);
c6a2a177 229
363d0f64 230DECLARE_EVENT_CLASS(hrtimer_class,
c6a2a177 231
434a83c3 232 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 233
434a83c3 234 TP_ARGS(hrtimer),
c6a2a177
XG
235
236 TP_STRUCT__entry(
434a83c3 237 __field( void *, hrtimer )
c6a2a177
XG
238 ),
239
240 TP_fast_assign(
434a83c3 241 __entry->hrtimer = hrtimer;
c6a2a177
XG
242 ),
243
434a83c3 244 TP_printk("hrtimer=%p", __entry->hrtimer)
c6a2a177
XG
245);
246
247/**
363d0f64 248 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
cf2fbdd2 249 * @hrtimer: pointer to struct hrtimer
363d0f64
LZ
250 *
251 * When used in combination with the hrtimer_expire_entry tracepoint we can
252 * determine the runtime of the callback function.
c6a2a177 253 */
363d0f64 254DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
c6a2a177 255
434a83c3 256 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 257
363d0f64
LZ
258 TP_ARGS(hrtimer)
259);
c6a2a177 260
363d0f64
LZ
261/**
262 * hrtimer_cancel - called when the hrtimer is canceled
263 * @hrtimer: pointer to struct hrtimer
264 */
265DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
c6a2a177 266
363d0f64 267 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 268
363d0f64 269 TP_ARGS(hrtimer)
c6a2a177
XG
270);
271
3f0a525e
XG
272/**
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,
858cf3a8 282 unsigned long long expires),
3f0a525e
XG
283
284 TP_ARGS(which, value, expires),
285
286 TP_STRUCT__entry(
858cf3a8
FW
287 __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 )
3f0a525e
XG
293 ),
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
e9c0748b 304 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
858cf3a8 305 __entry->which, __entry->expires,
3f0a525e
XG
306 __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
858cf3a8 318 TP_PROTO(int which, struct pid *pid, unsigned long long now),
3f0a525e
XG
319
320 TP_ARGS(which, pid, now),
321
322 TP_STRUCT__entry(
858cf3a8
FW
323 __field( int , which )
324 __field( pid_t, pid )
325 __field( unsigned long long, now )
3f0a525e
XG
326 ),
327
328 TP_fast_assign(
329 __entry->which = which;
330 __entry->now = now;
331 __entry->pid = pid_nr(pid);
332 ),
333
e9c0748b 334 TP_printk("which=%d pid=%d now=%llu", __entry->which,
858cf3a8 335 (int) __entry->pid, __entry->now)
3f0a525e
XG
336);
337
2c82d1be 338#ifdef CONFIG_NO_HZ_COMMON
e6e6cc22
FW
339
340#define TICK_DEP_NAMES \
c87edb36 341 tick_dep_mask_name(NONE) \
e6e6cc22
FW
342 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
c87edb36 348#undef tick_dep_mask_name
e6e6cc22
FW
349#undef tick_dep_name_end
350
c87edb36
SRRH
351/* 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);
e6e6cc22
FW
358
359TICK_DEP_NAMES
360
361#undef tick_dep_name
c87edb36 362#undef tick_dep_mask_name
e6e6cc22
FW
363#undef tick_dep_name_end
364
365#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
c87edb36 366#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
e6e6cc22
FW
367#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
cb41a290
FW
372TRACE_EVENT(tick_stop,
373
e6e6cc22 374 TP_PROTO(int success, int dependency),
cb41a290 375
e6e6cc22 376 TP_ARGS(success, dependency),
cb41a290
FW
377
378 TP_STRUCT__entry(
379 __field( int , success )
e6e6cc22 380 __field( int , dependency )
cb41a290
FW
381 ),
382
383 TP_fast_assign(
384 __entry->success = success;
e6e6cc22 385 __entry->dependency = dependency;
cb41a290
FW
386 ),
387
e6e6cc22
FW
388 TP_printk("success=%d dependency=%s", __entry->success, \
389 show_tick_dep_name(__entry->dependency))
cb41a290
FW
390);
391#endif
392
2b022e3d
XG
393#endif /* _TRACE_TIMER_H */
394
395/* This part must be outside protection */
396#include <trace/define_trace.h>