WIP FPC-III support
[linux/fpc-iii.git] / include / trace / events / timer.h
blob19abb6c3eb73f876c6054805eee015921b96e1b3
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM timer
5 #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_TIMER_H
8 #include <linux/tracepoint.h>
9 #include <linux/hrtimer.h>
10 #include <linux/timer.h>
12 DECLARE_EVENT_CLASS(timer_class,
14 TP_PROTO(struct timer_list *timer),
16 TP_ARGS(timer),
18 TP_STRUCT__entry(
19 __field( void *, timer )
22 TP_fast_assign(
23 __entry->timer = timer;
26 TP_printk("timer=%p", __entry->timer)
29 /**
30 * timer_init - called when the timer is initialized
31 * @timer: pointer to struct timer_list
33 DEFINE_EVENT(timer_class, timer_init,
35 TP_PROTO(struct timer_list *timer),
37 TP_ARGS(timer)
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" })
47 /**
48 * timer_start - called when the timer is started
49 * @timer: pointer to struct timer_list
50 * @expires: the timers expiry time
52 TRACE_EVENT(timer_start,
54 TP_PROTO(struct timer_list *timer,
55 unsigned long expires,
56 unsigned int flags),
58 TP_ARGS(timer, expires, flags),
60 TP_STRUCT__entry(
61 __field( void *, timer )
62 __field( void *, function )
63 __field( unsigned long, expires )
64 __field( unsigned long, now )
65 __field( unsigned int, flags )
68 TP_fast_assign(
69 __entry->timer = timer;
70 __entry->function = timer->function;
71 __entry->expires = expires;
72 __entry->now = jiffies;
73 __entry->flags = flags;
76 TP_printk("timer=%p function=%ps expires=%lu [timeout=%ld] cpu=%u idx=%u flags=%s",
77 __entry->timer, __entry->function, __entry->expires,
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))
84 /**
85 * timer_expire_entry - called immediately before the timer callback
86 * @timer: pointer to struct timer_list
88 * Allows to determine the timer latency.
90 TRACE_EVENT(timer_expire_entry,
92 TP_PROTO(struct timer_list *timer, unsigned long baseclk),
94 TP_ARGS(timer, baseclk),
96 TP_STRUCT__entry(
97 __field( void *, timer )
98 __field( unsigned long, now )
99 __field( void *, function)
100 __field( unsigned long, baseclk )
103 TP_fast_assign(
104 __entry->timer = timer;
105 __entry->now = jiffies;
106 __entry->function = timer->function;
107 __entry->baseclk = baseclk;
110 TP_printk("timer=%p function=%ps now=%lu baseclk=%lu",
111 __entry->timer, __entry->function, __entry->now,
112 __entry->baseclk)
116 * timer_expire_exit - called immediately after the timer callback returns
117 * @timer: pointer to struct timer_list
119 * When used in combination with the timer_expire_entry tracepoint we can
120 * determine the runtime of the timer callback function.
122 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
123 * be invalid. We solely track the pointer.
125 DEFINE_EVENT(timer_class, timer_expire_exit,
127 TP_PROTO(struct timer_list *timer),
129 TP_ARGS(timer)
133 * timer_cancel - called when the timer is canceled
134 * @timer: pointer to struct timer_list
136 DEFINE_EVENT(timer_class, timer_cancel,
138 TP_PROTO(struct timer_list *timer),
140 TP_ARGS(timer)
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" })
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" }, \
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" })
162 * hrtimer_init - called when the hrtimer is initialized
163 * @hrtimer: pointer to struct hrtimer
164 * @clockid: the hrtimers clock
165 * @mode: the hrtimers mode
167 TRACE_EVENT(hrtimer_init,
169 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
170 enum hrtimer_mode mode),
172 TP_ARGS(hrtimer, clockid, mode),
174 TP_STRUCT__entry(
175 __field( void *, hrtimer )
176 __field( clockid_t, clockid )
177 __field( enum hrtimer_mode, mode )
180 TP_fast_assign(
181 __entry->hrtimer = hrtimer;
182 __entry->clockid = clockid;
183 __entry->mode = mode;
186 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
187 decode_clockid(__entry->clockid),
188 decode_hrtimer_mode(__entry->mode))
192 * hrtimer_start - called when the hrtimer is started
193 * @hrtimer: pointer to struct hrtimer
195 TRACE_EVENT(hrtimer_start,
197 TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode),
199 TP_ARGS(hrtimer, mode),
201 TP_STRUCT__entry(
202 __field( void *, hrtimer )
203 __field( void *, function )
204 __field( s64, expires )
205 __field( s64, softexpires )
206 __field( enum hrtimer_mode, mode )
209 TP_fast_assign(
210 __entry->hrtimer = hrtimer;
211 __entry->function = hrtimer->function;
212 __entry->expires = hrtimer_get_expires(hrtimer);
213 __entry->softexpires = hrtimer_get_softexpires(hrtimer);
214 __entry->mode = mode;
217 TP_printk("hrtimer=%p function=%ps expires=%llu softexpires=%llu "
218 "mode=%s", __entry->hrtimer, __entry->function,
219 (unsigned long long) __entry->expires,
220 (unsigned long long) __entry->softexpires,
221 decode_hrtimer_mode(__entry->mode))
225 * hrtimer_expire_entry - called immediately before the hrtimer callback
226 * @hrtimer: pointer to struct hrtimer
227 * @now: pointer to variable which contains current time of the
228 * timers base.
230 * Allows to determine the timer latency.
232 TRACE_EVENT(hrtimer_expire_entry,
234 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
236 TP_ARGS(hrtimer, now),
238 TP_STRUCT__entry(
239 __field( void *, hrtimer )
240 __field( s64, now )
241 __field( void *, function)
244 TP_fast_assign(
245 __entry->hrtimer = hrtimer;
246 __entry->now = *now;
247 __entry->function = hrtimer->function;
250 TP_printk("hrtimer=%p function=%ps now=%llu",
251 __entry->hrtimer, __entry->function,
252 (unsigned long long) __entry->now)
255 DECLARE_EVENT_CLASS(hrtimer_class,
257 TP_PROTO(struct hrtimer *hrtimer),
259 TP_ARGS(hrtimer),
261 TP_STRUCT__entry(
262 __field( void *, hrtimer )
265 TP_fast_assign(
266 __entry->hrtimer = hrtimer;
269 TP_printk("hrtimer=%p", __entry->hrtimer)
273 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
274 * @hrtimer: pointer to struct hrtimer
276 * When used in combination with the hrtimer_expire_entry tracepoint we can
277 * determine the runtime of the callback function.
279 DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
281 TP_PROTO(struct hrtimer *hrtimer),
283 TP_ARGS(hrtimer)
287 * hrtimer_cancel - called when the hrtimer is canceled
288 * @hrtimer: pointer to struct hrtimer
290 DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
292 TP_PROTO(struct hrtimer *hrtimer),
294 TP_ARGS(hrtimer)
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
304 TRACE_EVENT(itimer_state,
306 TP_PROTO(int which, const struct itimerspec64 *const value,
307 unsigned long long expires),
309 TP_ARGS(which, value, expires),
311 TP_STRUCT__entry(
312 __field( int, which )
313 __field( unsigned long long, expires )
314 __field( long, value_sec )
315 __field( long, value_nsec )
316 __field( long, interval_sec )
317 __field( long, interval_nsec )
320 TP_fast_assign(
321 __entry->which = which;
322 __entry->expires = expires;
323 __entry->value_sec = value->it_value.tv_sec;
324 __entry->value_nsec = value->it_value.tv_nsec;
325 __entry->interval_sec = value->it_interval.tv_sec;
326 __entry->interval_nsec = value->it_interval.tv_nsec;
329 TP_printk("which=%d expires=%llu it_value=%ld.%06ld it_interval=%ld.%06ld",
330 __entry->which, __entry->expires,
331 __entry->value_sec, __entry->value_nsec / NSEC_PER_USEC,
332 __entry->interval_sec, __entry->interval_nsec / NSEC_PER_USEC)
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
341 TRACE_EVENT(itimer_expire,
343 TP_PROTO(int which, struct pid *pid, unsigned long long now),
345 TP_ARGS(which, pid, now),
347 TP_STRUCT__entry(
348 __field( int , which )
349 __field( pid_t, pid )
350 __field( unsigned long long, now )
353 TP_fast_assign(
354 __entry->which = which;
355 __entry->now = now;
356 __entry->pid = pid_nr(pid);
359 TP_printk("which=%d pid=%d now=%llu", __entry->which,
360 (int) __entry->pid, __entry->now)
363 #ifdef CONFIG_NO_HZ_COMMON
365 #define TICK_DEP_NAMES \
366 tick_dep_mask_name(NONE) \
367 tick_dep_name(POSIX_TIMER) \
368 tick_dep_name(PERF_EVENTS) \
369 tick_dep_name(SCHED) \
370 tick_dep_name(CLOCK_UNSTABLE) \
371 tick_dep_name_end(RCU)
373 #undef tick_dep_name
374 #undef tick_dep_mask_name
375 #undef tick_dep_name_end
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);
385 TICK_DEP_NAMES
387 #undef tick_dep_name
388 #undef tick_dep_mask_name
389 #undef tick_dep_name_end
391 #define tick_dep_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
392 #define tick_dep_mask_name(sdep) { TICK_DEP_MASK_##sdep, #sdep },
393 #define tick_dep_name_end(sdep) { TICK_DEP_MASK_##sdep, #sdep }
395 #define show_tick_dep_name(val) \
396 __print_symbolic(val, TICK_DEP_NAMES)
398 TRACE_EVENT(tick_stop,
400 TP_PROTO(int success, int dependency),
402 TP_ARGS(success, dependency),
404 TP_STRUCT__entry(
405 __field( int , success )
406 __field( int , dependency )
409 TP_fast_assign(
410 __entry->success = success;
411 __entry->dependency = dependency;
414 TP_printk("success=%d dependency=%s", __entry->success, \
415 show_tick_dep_name(__entry->dependency))
417 #endif
419 #endif /* _TRACE_TIMER_H */
421 /* This part must be outside protection */
422 #include <trace/define_trace.h>