2 #define TRACE_SYSTEM timer
4 #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_TIMER_H
7 #include "../../../probes/lttng-tracepoint-event.h"
9 #ifndef _TRACE_TIMER_DEF_
10 #define _TRACE_TIMER_DEF_
11 #include <linux/hrtimer.h>
12 #include <linux/timer.h>
13 #include <linux/version.h>
17 #endif /* _TRACE_TIMER_DEF_ */
19 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class
,
21 TP_PROTO(struct timer_list
*timer
),
26 __field( void *, timer
)
30 tp_assign(timer
, timer
)
33 TP_printk("timer=%p", __entry
->timer
)
37 * timer_init - called when the timer is initialized
38 * @timer: pointer to struct timer_list
40 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_init
,
42 TP_PROTO(struct timer_list
*timer
),
47 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0))
49 * timer_start - called when the timer is started
50 * @timer: pointer to struct timer_list
51 * @expires: the timers expiry time
52 * @flags: the timers expiry time
54 LTTNG_TRACEPOINT_EVENT(timer_start
,
56 TP_PROTO(struct timer_list
*timer
, unsigned long expires
,
59 TP_ARGS(timer
, expires
, flags
),
62 __field( void *, timer
)
63 __field( void *, function
)
64 __field( unsigned long, expires
)
65 __field( unsigned long, now
)
66 __field( unsigned int, flags
)
70 tp_assign(timer
, timer
)
71 tp_assign(function
, timer
->function
)
72 tp_assign(expires
, expires
)
73 tp_assign(now
, jiffies
)
74 tp_assign(flags
, flags
)
79 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
81 * timer_start - called when the timer is started
82 * @timer: pointer to struct timer_list
83 * @expires: the timers expiry time
85 LTTNG_TRACEPOINT_EVENT(timer_start
,
87 TP_PROTO(struct timer_list
*timer
, unsigned long expires
),
89 TP_ARGS(timer
, expires
),
92 __field( void *, timer
)
93 __field( void *, function
)
94 __field( unsigned long, expires
)
95 __field( unsigned long, now
)
99 tp_assign(timer
, timer
)
100 tp_assign(function
, timer
->function
)
101 tp_assign(expires
, expires
)
102 tp_assign(now
, jiffies
)
105 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
106 __entry
->timer
, __entry
->function
, __entry
->expires
,
107 (long)__entry
->expires
- __entry
->now
)
109 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
112 * timer_expire_entry - called immediately before the timer callback
113 * @timer: pointer to struct timer_list
115 * Allows to determine the timer latency.
117 LTTNG_TRACEPOINT_EVENT(timer_expire_entry
,
119 TP_PROTO(struct timer_list
*timer
),
124 __field( void *, timer
)
125 __field( unsigned long, now
)
126 __field( void *, function
)
130 tp_assign(timer
, timer
)
131 tp_assign(now
, jiffies
)
132 tp_assign(function
, timer
->function
)
135 TP_printk("timer=%p function=%pf now=%lu", __entry
->timer
, __entry
->function
,__entry
->now
)
139 * timer_expire_exit - called immediately after the timer callback returns
140 * @timer: pointer to struct timer_list
142 * When used in combination with the timer_expire_entry tracepoint we can
143 * determine the runtime of the timer callback function.
145 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
146 * be invalid. We solely track the pointer.
148 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_expire_exit
,
150 TP_PROTO(struct timer_list
*timer
),
156 * timer_cancel - called when the timer is canceled
157 * @timer: pointer to struct timer_list
159 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class
, timer_cancel
,
161 TP_PROTO(struct timer_list
*timer
),
167 * hrtimer_init - called when the hrtimer is initialized
168 * @timer: pointer to struct hrtimer
169 * @clockid: the hrtimers clock
170 * @mode: the hrtimers mode
172 LTTNG_TRACEPOINT_EVENT(hrtimer_init
,
174 TP_PROTO(struct hrtimer
*hrtimer
, clockid_t clockid
,
175 enum hrtimer_mode mode
),
177 TP_ARGS(hrtimer
, clockid
, mode
),
180 __field( void *, hrtimer
)
181 __field( clockid_t
, clockid
)
182 __field( enum hrtimer_mode
, mode
)
186 tp_assign(hrtimer
, hrtimer
)
187 tp_assign(clockid
, clockid
)
188 tp_assign(mode
, mode
)
191 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry
->hrtimer
,
192 __entry
->clockid
== CLOCK_REALTIME
?
193 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
194 __entry
->mode
== HRTIMER_MODE_ABS
?
195 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
199 * hrtimer_start - called when the hrtimer is started
200 * @timer: pointer to struct hrtimer
202 LTTNG_TRACEPOINT_EVENT(hrtimer_start
,
204 TP_PROTO(struct hrtimer
*hrtimer
),
209 __field( void *, hrtimer
)
210 __field( void *, function
)
211 __field( s64
, expires
)
212 __field( s64
, softexpires
)
216 tp_assign(hrtimer
, hrtimer
)
217 tp_assign(function
, hrtimer
->function
)
218 tp_assign(expires
, hrtimer_get_expires(hrtimer
).tv64
)
219 tp_assign(softexpires
, hrtimer_get_softexpires(hrtimer
).tv64
)
222 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
223 __entry
->hrtimer
, __entry
->function
,
224 (unsigned long long)ktime_to_ns((ktime_t
) {
225 .tv64
= __entry
->expires
}),
226 (unsigned long long)ktime_to_ns((ktime_t
) {
227 .tv64
= __entry
->softexpires
}))
231 * htimmer_expire_entry - called immediately before the hrtimer callback
232 * @timer: pointer to struct hrtimer
233 * @now: pointer to variable which contains current time of the
236 * Allows to determine the timer latency.
238 LTTNG_TRACEPOINT_EVENT(hrtimer_expire_entry
,
240 TP_PROTO(struct hrtimer
*hrtimer
, ktime_t
*now
),
242 TP_ARGS(hrtimer
, now
),
245 __field( void *, hrtimer
)
247 __field( void *, function
)
251 tp_assign(hrtimer
, hrtimer
)
252 tp_assign(now
, now
->tv64
)
253 tp_assign(function
, hrtimer
->function
)
256 TP_printk("hrtimer=%p function=%pf now=%llu", __entry
->hrtimer
, __entry
->function
,
257 (unsigned long long)ktime_to_ns((ktime_t
) { .tv64
= __entry
->now
}))
260 LTTNG_TRACEPOINT_EVENT_CLASS(hrtimer_class
,
262 TP_PROTO(struct hrtimer
*hrtimer
),
267 __field( void *, hrtimer
)
271 tp_assign(hrtimer
, hrtimer
)
274 TP_printk("hrtimer=%p", __entry
->hrtimer
)
278 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
279 * @timer: pointer to struct hrtimer
281 * When used in combination with the hrtimer_expire_entry tracepoint we can
282 * determine the runtime of the callback function.
284 LTTNG_TRACEPOINT_EVENT_INSTANCE(hrtimer_class
, hrtimer_expire_exit
,
286 TP_PROTO(struct hrtimer
*hrtimer
),
292 * hrtimer_cancel - called when the hrtimer is canceled
293 * @hrtimer: pointer to struct hrtimer
295 LTTNG_TRACEPOINT_EVENT_INSTANCE(hrtimer_class
, hrtimer_cancel
,
297 TP_PROTO(struct hrtimer
*hrtimer
),
303 * itimer_state - called when itimer is started or canceled
304 * @which: name of the interval timer
305 * @value: the itimers value, itimer is canceled if value->it_value is
306 * zero, otherwise it is started
307 * @expires: the itimers expiry time
309 LTTNG_TRACEPOINT_EVENT(itimer_state
,
311 TP_PROTO(int which
, const struct itimerval
*const value
,
314 TP_ARGS(which
, value
, expires
),
317 __field( int, which
)
318 __field( cputime_t
, expires
)
319 __field( long, value_sec
)
320 __field( long, value_usec
)
321 __field( long, interval_sec
)
322 __field( long, interval_usec
)
326 tp_assign(which
, which
)
327 tp_assign(expires
, expires
)
328 tp_assign(value_sec
, value
->it_value
.tv_sec
)
329 tp_assign(value_usec
, value
->it_value
.tv_usec
)
330 tp_assign(interval_sec
, value
->it_interval
.tv_sec
)
331 tp_assign(interval_usec
, value
->it_interval
.tv_usec
)
334 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
335 __entry
->which
, (unsigned long long)__entry
->expires
,
336 __entry
->value_sec
, __entry
->value_usec
,
337 __entry
->interval_sec
, __entry
->interval_usec
)
341 * itimer_expire - called when itimer expires
342 * @which: type of the interval timer
343 * @pid: pid of the process which owns the timer
344 * @now: current time, used to calculate the latency of itimer
346 LTTNG_TRACEPOINT_EVENT(itimer_expire
,
348 TP_PROTO(int which
, struct pid
*pid
, cputime_t now
),
350 TP_ARGS(which
, pid
, now
),
353 __field( int , which
)
354 __field( pid_t
, pid
)
355 __field( cputime_t
, now
)
359 tp_assign(which
, which
)
361 tp_assign(pid
, pid_nr(pid
))
364 TP_printk("which=%d pid=%d now=%llu", __entry
->which
,
365 (int) __entry
->pid
, (unsigned long long)__entry
->now
)
368 #endif /* LTTNG_TRACE_TIMER_H */
370 /* This part must be outside protection */
371 #include "../../../probes/define_trace.h"
This page took 0.039399 seconds and 4 git commands to generate.