nohz: Add TICK_DEP_BIT_RCU
[linux-2.6-block.git] / include / trace / events / timer.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
2b022e3d
XG
2#undef TRACE_SYSTEM
3#define TRACE_SYSTEM timer
4
5#if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_TIMER_H
7
8#include <linux/tracepoint.h>
c6a2a177 9#include <linux/hrtimer.h>
2b022e3d
XG
10#include <linux/timer.h>
11
363d0f64 12DECLARE_EVENT_CLASS(timer_class,
2b022e3d
XG
13
14 TP_PROTO(struct timer_list *timer),
15
16 TP_ARGS(timer),
17
18 TP_STRUCT__entry(
19 __field( void *, timer )
20 ),
21
22 TP_fast_assign(
23 __entry->timer = timer;
24 ),
25
434a83c3 26 TP_printk("timer=%p", __entry->timer)
2b022e3d
XG
27);
28
363d0f64
LZ
29/**
30 * timer_init - called when the timer is initialized
31 * @timer: pointer to struct timer_list
32 */
33DEFINE_EVENT(timer_class, timer_init,
34
35 TP_PROTO(struct timer_list *timer),
36
37 TP_ARGS(timer)
38);
39
8a58a34b
TG
40#define decode_timer_flags(flags) \
41 __print_flags(flags, "|", \
42 { TIMER_MIGRATING, "M" }, \
43 { TIMER_DEFERRABLE, "D" }, \
44 { TIMER_PINNED, "P" }, \
45 { TIMER_IRQSAFE, "I" })
46
2b022e3d
XG
47/**
48 * timer_start - called when the timer is started
49 * @timer: pointer to struct timer_list
50 * @expires: the timers expiry time
51 */
52TRACE_EVENT(timer_start,
53
4e413e85
BJS
54 TP_PROTO(struct timer_list *timer,
55 unsigned long expires,
0eeda71b 56 unsigned int flags),
2b022e3d 57
0eeda71b 58 TP_ARGS(timer, expires, flags),
2b022e3d
XG
59
60 TP_STRUCT__entry(
61 __field( void *, timer )
62 __field( void *, function )
63 __field( unsigned long, expires )
64 __field( unsigned long, now )
0eeda71b 65 __field( unsigned int, flags )
2b022e3d
XG
66 ),
67
68 TP_fast_assign(
69 __entry->timer = timer;
70 __entry->function = timer->function;
71 __entry->expires = expires;
72 __entry->now = jiffies;
0eeda71b 73 __entry->flags = flags;
2b022e3d
XG
74 ),
75
6849cbb0 76 TP_printk("timer=%p function=%ps expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
2b022e3d 77 __entry->timer, __entry->function, __entry->expires,
8a58a34b
TG
78 (long)__entry->expires - __entry->now,
79 __entry->flags & TIMER_CPUMASK,
80 __entry->flags >> TIMER_ARRAYSHIFT,
81 decode_timer_flags(__entry->flags & TIMER_TRACE_FLAGMASK))
2b022e3d
XG
82);
83
84/**
85 * timer_expire_entry - called immediately before the timer callback
86 * @timer: pointer to struct timer_list
87 *
88 * Allows to determine the timer latency.
89 */
90TRACE_EVENT(timer_expire_entry,
91
f28d3d53 92 TP_PROTO(struct timer_list *timer, unsigned long baseclk),
2b022e3d 93
f28d3d53 94 TP_ARGS(timer, baseclk),
2b022e3d
XG
95
96 TP_STRUCT__entry(
97 __field( void *, timer )
98 __field( unsigned long, now )
ede1b429 99 __field( void *, function)
f28d3d53 100 __field( unsigned long, baseclk )
2b022e3d
XG
101 ),
102
103 TP_fast_assign(
104 __entry->timer = timer;
105 __entry->now = jiffies;
ede1b429 106 __entry->function = timer->function;
f28d3d53 107 __entry->baseclk = baseclk;
2b022e3d
XG
108 ),
109
f28d3d53
AMG
110 TP_printk("timer=%p function=%ps now=%lu baseclk=%lu",
111 __entry->timer, __entry->function, __entry->now,
112 __entry->baseclk)
2b022e3d
XG
113);
114
115/**
116 * timer_expire_exit - called immediately after the timer callback returns
117 * @timer: pointer to struct timer_list
118 *
119 * When used in combination with the timer_expire_entry tracepoint we can
120 * determine the runtime of the timer callback function.
121 *
122 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
123 * be invalid. We solely track the pointer.
124 */
363d0f64 125DEFINE_EVENT(timer_class, timer_expire_exit,
2b022e3d
XG
126
127 TP_PROTO(struct timer_list *timer),
128
363d0f64 129 TP_ARGS(timer)
2b022e3d
XG
130);
131
132/**
133 * timer_cancel - called when the timer is canceled
134 * @timer: pointer to struct timer_list
135 */
363d0f64 136DEFINE_EVENT(timer_class, timer_cancel,
2b022e3d
XG
137
138 TP_PROTO(struct timer_list *timer),
139
363d0f64 140 TP_ARGS(timer)
2b022e3d
XG
141);
142
91633eed
AMG
143#define decode_clockid(type) \
144 __print_symbolic(type, \
145 { CLOCK_REALTIME, "CLOCK_REALTIME" }, \
146 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, \
147 { CLOCK_BOOTTIME, "CLOCK_BOOTTIME" }, \
148 { CLOCK_TAI, "CLOCK_TAI" })
149
150#define decode_hrtimer_mode(mode) \
151 __print_symbolic(mode, \
152 { HRTIMER_MODE_ABS, "ABS" }, \
153 { HRTIMER_MODE_REL, "REL" }, \
154 { HRTIMER_MODE_ABS_PINNED, "ABS|PINNED" }, \
98ecadd4
AMG
155 { HRTIMER_MODE_REL_PINNED, "REL|PINNED" }, \
156 { HRTIMER_MODE_ABS_SOFT, "ABS|SOFT" }, \
157 { HRTIMER_MODE_REL_SOFT, "REL|SOFT" }, \
158 { HRTIMER_MODE_ABS_PINNED_SOFT, "ABS|PINNED|SOFT" }, \
159 { HRTIMER_MODE_REL_PINNED_SOFT, "REL|PINNED|SOFT" })
91633eed 160
c6a2a177
XG
161/**
162 * hrtimer_init - called when the hrtimer is initialized
cf2fbdd2 163 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
164 * @clockid: the hrtimers clock
165 * @mode: the hrtimers mode
166 */
167TRACE_EVENT(hrtimer_init,
168
434a83c3 169 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
c6a2a177
XG
170 enum hrtimer_mode mode),
171
434a83c3 172 TP_ARGS(hrtimer, clockid, mode),
c6a2a177
XG
173
174 TP_STRUCT__entry(
434a83c3 175 __field( void *, hrtimer )
c6a2a177
XG
176 __field( clockid_t, clockid )
177 __field( enum hrtimer_mode, mode )
178 ),
179
180 TP_fast_assign(
434a83c3 181 __entry->hrtimer = hrtimer;
c6a2a177
XG
182 __entry->clockid = clockid;
183 __entry->mode = mode;
184 ),
185
434a83c3 186 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
91633eed
AMG
187 decode_clockid(__entry->clockid),
188 decode_hrtimer_mode(__entry->mode))
c6a2a177
XG
189);
190
191/**
192 * hrtimer_start - called when the hrtimer is started
cf2fbdd2 193 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
194 */
195TRACE_EVENT(hrtimer_start,
196
63e2ed36 197 TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode),
c6a2a177 198
63e2ed36 199 TP_ARGS(hrtimer, mode),
c6a2a177
XG
200
201 TP_STRUCT__entry(
434a83c3 202 __field( void *, hrtimer )
c6a2a177
XG
203 __field( void *, function )
204 __field( s64, expires )
205 __field( s64, softexpires )
63e2ed36 206 __field( enum hrtimer_mode, mode )
c6a2a177
XG
207 ),
208
209 TP_fast_assign(
434a83c3
IM
210 __entry->hrtimer = hrtimer;
211 __entry->function = hrtimer->function;
2456e855
TG
212 __entry->expires = hrtimer_get_expires(hrtimer);
213 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
63e2ed36 214 __entry->mode = mode;
c6a2a177
XG
215 ),
216
6849cbb0 217 TP_printk("hrtimer=%p function=%ps expires=%llu softexpires=%llu "
63e2ed36 218 "mode=%s", __entry->hrtimer, __entry->function,
2456e855 219 (unsigned long long) __entry->expires,
63e2ed36
AMG
220 (unsigned long long) __entry->softexpires,
221 decode_hrtimer_mode(__entry->mode))
c6a2a177
XG
222);
223
224/**
cf2fbdd2
MI
225 * hrtimer_expire_entry - called immediately before the hrtimer callback
226 * @hrtimer: pointer to struct hrtimer
c6a2a177
XG
227 * @now: pointer to variable which contains current time of the
228 * timers base.
229 *
230 * Allows to determine the timer latency.
231 */
232TRACE_EVENT(hrtimer_expire_entry,
233
434a83c3 234 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
c6a2a177 235
434a83c3 236 TP_ARGS(hrtimer, now),
c6a2a177
XG
237
238 TP_STRUCT__entry(
434a83c3 239 __field( void *, hrtimer )
c6a2a177 240 __field( s64, now )
ede1b429 241 __field( void *, function)
c6a2a177
XG
242 ),
243
244 TP_fast_assign(
434a83c3 245 __entry->hrtimer = hrtimer;
2456e855 246 __entry->now = *now;
ede1b429 247 __entry->function = hrtimer->function;
c6a2a177
XG
248 ),
249
6849cbb0
AMG
250 TP_printk("hrtimer=%p function=%ps now=%llu",
251 __entry->hrtimer, __entry->function,
2456e855
TG
252 (unsigned long long) __entry->now)
253);
c6a2a177 254
363d0f64 255DECLARE_EVENT_CLASS(hrtimer_class,
c6a2a177 256
434a83c3 257 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 258
434a83c3 259 TP_ARGS(hrtimer),
c6a2a177
XG
260
261 TP_STRUCT__entry(
434a83c3 262 __field( void *, hrtimer )
c6a2a177
XG
263 ),
264
265 TP_fast_assign(
434a83c3 266 __entry->hrtimer = hrtimer;
c6a2a177
XG
267 ),
268
434a83c3 269 TP_printk("hrtimer=%p", __entry->hrtimer)
c6a2a177
XG
270);
271
272/**
363d0f64 273 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
cf2fbdd2 274 * @hrtimer: pointer to struct hrtimer
363d0f64
LZ
275 *
276 * When used in combination with the hrtimer_expire_entry tracepoint we can
277 * determine the runtime of the callback function.
c6a2a177 278 */
363d0f64 279DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
c6a2a177 280
434a83c3 281 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 282
363d0f64
LZ
283 TP_ARGS(hrtimer)
284);
c6a2a177 285
363d0f64
LZ
286/**
287 * hrtimer_cancel - called when the hrtimer is canceled
288 * @hrtimer: pointer to struct hrtimer
289 */
290DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
c6a2a177 291
363d0f64 292 TP_PROTO(struct hrtimer *hrtimer),
c6a2a177 293
363d0f64 294 TP_ARGS(hrtimer)
c6a2a177
XG
295);
296
3f0a525e
XG
297/**
298 * itimer_state - called when itimer is started or canceled
299 * @which: name of the interval timer
300 * @value: the itimers value, itimer is canceled if value->it_value is
301 * zero, otherwise it is started
302 * @expires: the itimers expiry time
303 */
304TRACE_EVENT(itimer_state,
305
306 TP_PROTO(int which, const struct itimerval *const value,
858cf3a8 307 unsigned long long expires),
3f0a525e
XG
308
309 TP_ARGS(which, value, expires),
310
311 TP_STRUCT__entry(
858cf3a8
FW
312 __field( int, which )
313 __field( unsigned long long, expires )
314 __field( long, value_sec )
315 __field( long, value_usec )
316 __field( long, interval_sec )
317 __field( long, interval_usec )
3f0a525e
XG
318 ),
319
320 TP_fast_assign(
321 __entry->which = which;
322 __entry->expires = expires;
323 __entry->value_sec = value->it_value.tv_sec;
324 __entry->value_usec = value->it_value.tv_usec;
325 __entry->interval_sec = value->it_interval.tv_sec;
326 __entry->interval_usec = value->it_interval.tv_usec;
327 ),
328
e9c0748b 329 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
858cf3a8 330 __entry->which, __entry->expires,
3f0a525e
XG
331 __entry->value_sec, __entry->value_usec,
332 __entry->interval_sec, __entry->interval_usec)
333);
334
335/**
336 * itimer_expire - called when itimer expires
337 * @which: type of the interval timer
338 * @pid: pid of the process which owns the timer
339 * @now: current time, used to calculate the latency of itimer
340 */
341TRACE_EVENT(itimer_expire,
342
858cf3a8 343 TP_PROTO(int which, struct pid *pid, unsigned long long now),
3f0a525e
XG
344
345 TP_ARGS(which, pid, now),
346
347 TP_STRUCT__entry(
858cf3a8
FW
348 __field( int , which )
349 __field( pid_t, pid )
350 __field( unsigned long long, now )
3f0a525e
XG
351 ),
352
353 TP_fast_assign(
354 __entry->which = which;
355 __entry->now = now;
356 __entry->pid = pid_nr(pid);
357 ),
358
e9c0748b 359 TP_printk("which=%d pid=%d now=%llu", __entry->which,
858cf3a8 360 (int) __entry->pid, __entry->now)
3f0a525e
XG
361);
362
2c82d1be 363#ifdef CONFIG_NO_HZ_COMMON
e6e6cc22
FW
364
365#define TICK_DEP_NAMES \
c87edb36 366 tick_dep_mask_name(NONE) \
e6e6cc22
FW
367 tick_dep_name(POSIX_TIMER) \
368 tick_dep_name(PERF_EVENTS) \
369 tick_dep_name(SCHED) \
01b4c399
FW
370 tick_dep_name(CLOCK_UNSTABLE) \
371 tick_dep_name_end(RCU)
e6e6cc22
FW
372
373#undef tick_dep_name
c87edb36 374#undef tick_dep_mask_name
e6e6cc22
FW
375#undef tick_dep_name_end
376
c87edb36
SRRH
377/* The MASK will convert to their bits and they need to be processed too */
378#define tick_dep_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
379 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
380#define tick_dep_name_end(sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \
381 TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
382/* NONE only has a mask defined for it */
383#define tick_dep_mask_name(sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep);
e6e6cc22
FW
384
385TICK_DEP_NAMES
386
387#undef tick_dep_name
c87edb36 388#undef tick_dep_mask_name
e6e6cc22
FW
389#undef tick_dep_name_end
390
391#define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
c87edb36 392#define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
e6e6cc22
FW
393#define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
394
395#define show_tick_dep_name(val) \
396 __print_symbolic(val, TICK_DEP_NAMES)
397
cb41a290
FW
398TRACE_EVENT(tick_stop,
399
e6e6cc22 400 TP_PROTO(int success, int dependency),
cb41a290 401
e6e6cc22 402 TP_ARGS(success, dependency),
cb41a290
FW
403
404 TP_STRUCT__entry(
405 __field( int , success )
e6e6cc22 406 __field( int , dependency )
cb41a290
FW
407 ),
408
409 TP_fast_assign(
410 __entry->success = success;
e6e6cc22 411 __entry->dependency = dependency;
cb41a290
FW
412 ),
413
e6e6cc22
FW
414 TP_printk("success=%d dependency=%s", __entry->success, \
415 show_tick_dep_name(__entry->dependency))
cb41a290
FW
416);
417#endif
418
2b022e3d
XG
419#endif /* _TRACE_TIMER_H */
420
421/* This part must be outside protection */
422#include <trace/define_trace.h>