Namespace all tracepoints
[lttng-modules.git] / instrumentation / events / lttng-module / timer.h
CommitLineData
e54456f5
MD
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM timer
3
3bc29f0a
MD
4#if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5#define LTTNG_TRACE_TIMER_H
e54456f5 6
3bc29f0a 7#include "../../../probes/lttng-tracepoint-event.h"
e54456f5
MD
8
9#ifndef _TRACE_TIMER_DEF_
10#define _TRACE_TIMER_DEF_
11#include <linux/hrtimer.h>
12#include <linux/timer.h>
3a523f5b
MD
13
14struct timer_list;
15
e54456f5
MD
16#endif /* _TRACE_TIMER_DEF_ */
17
3bc29f0a 18LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
e54456f5
MD
19
20 TP_PROTO(struct timer_list *timer),
21
22 TP_ARGS(timer),
23
24 TP_STRUCT__entry(
25 __field( void *, timer )
26 ),
27
28 TP_fast_assign(
29 tp_assign(timer, timer)
30 ),
31
32 TP_printk("timer=%p", __entry->timer)
33)
34
35/**
36 * timer_init - called when the timer is initialized
37 * @timer: pointer to struct timer_list
38 */
3bc29f0a 39LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
e54456f5
MD
40
41 TP_PROTO(struct timer_list *timer),
42
43 TP_ARGS(timer)
44)
45
46/**
47 * timer_start - called when the timer is started
48 * @timer: pointer to struct timer_list
49 * @expires: the timers expiry time
50 */
3bc29f0a 51LTTNG_TRACEPOINT_EVENT(timer_start,
e54456f5
MD
52
53 TP_PROTO(struct timer_list *timer, unsigned long expires),
54
55 TP_ARGS(timer, expires),
56
57 TP_STRUCT__entry(
58 __field( void *, timer )
59 __field( void *, function )
60 __field( unsigned long, expires )
61 __field( unsigned long, now )
62 ),
63
64 TP_fast_assign(
65 tp_assign(timer, timer)
66 tp_assign(function, timer->function)
67 tp_assign(expires, expires)
68 tp_assign(now, jiffies)
69 ),
70
71 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
72 __entry->timer, __entry->function, __entry->expires,
73 (long)__entry->expires - __entry->now)
74)
75
76/**
77 * timer_expire_entry - called immediately before the timer callback
78 * @timer: pointer to struct timer_list
79 *
80 * Allows to determine the timer latency.
81 */
3bc29f0a 82LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
e54456f5
MD
83
84 TP_PROTO(struct timer_list *timer),
85
86 TP_ARGS(timer),
87
88 TP_STRUCT__entry(
89 __field( void *, timer )
90 __field( unsigned long, now )
91 __field( void *, function)
92 ),
93
94 TP_fast_assign(
95 tp_assign(timer, timer)
96 tp_assign(now, jiffies)
97 tp_assign(function, timer->function)
98 ),
99
100 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
101)
102
103/**
104 * timer_expire_exit - called immediately after the timer callback returns
105 * @timer: pointer to struct timer_list
106 *
107 * When used in combination with the timer_expire_entry tracepoint we can
108 * determine the runtime of the timer callback function.
109 *
110 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
111 * be invalid. We solely track the pointer.
112 */
3bc29f0a 113LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
e54456f5
MD
114
115 TP_PROTO(struct timer_list *timer),
116
117 TP_ARGS(timer)
118)
119
120/**
121 * timer_cancel - called when the timer is canceled
122 * @timer: pointer to struct timer_list
123 */
3bc29f0a 124LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
e54456f5
MD
125
126 TP_PROTO(struct timer_list *timer),
127
128 TP_ARGS(timer)
129)
130
131/**
132 * hrtimer_init - called when the hrtimer is initialized
133 * @timer: pointer to struct hrtimer
134 * @clockid: the hrtimers clock
135 * @mode: the hrtimers mode
136 */
9bbf98da
MD
137LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
138
139 timer_hrtimer_init,
e54456f5
MD
140
141 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
142 enum hrtimer_mode mode),
143
144 TP_ARGS(hrtimer, clockid, mode),
145
146 TP_STRUCT__entry(
147 __field( void *, hrtimer )
148 __field( clockid_t, clockid )
149 __field( enum hrtimer_mode, mode )
150 ),
151
152 TP_fast_assign(
153 tp_assign(hrtimer, hrtimer)
154 tp_assign(clockid, clockid)
155 tp_assign(mode, mode)
156 ),
157
158 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
159 __entry->clockid == CLOCK_REALTIME ?
160 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
161 __entry->mode == HRTIMER_MODE_ABS ?
162 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
163)
164
165/**
166 * hrtimer_start - called when the hrtimer is started
167 * @timer: pointer to struct hrtimer
168 */
9bbf98da
MD
169LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
170
171 timer_hrtimer_start,
e54456f5
MD
172
173 TP_PROTO(struct hrtimer *hrtimer),
174
175 TP_ARGS(hrtimer),
176
177 TP_STRUCT__entry(
178 __field( void *, hrtimer )
179 __field( void *, function )
180 __field( s64, expires )
181 __field( s64, softexpires )
182 ),
183
184 TP_fast_assign(
185 tp_assign(hrtimer, hrtimer)
186 tp_assign(function, hrtimer->function)
187 tp_assign(expires, hrtimer_get_expires(hrtimer).tv64)
188 tp_assign(softexpires, hrtimer_get_softexpires(hrtimer).tv64)
189 ),
190
191 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
192 __entry->hrtimer, __entry->function,
193 (unsigned long long)ktime_to_ns((ktime_t) {
194 .tv64 = __entry->expires }),
195 (unsigned long long)ktime_to_ns((ktime_t) {
196 .tv64 = __entry->softexpires }))
197)
198
199/**
200 * htimmer_expire_entry - called immediately before the hrtimer callback
201 * @timer: pointer to struct hrtimer
202 * @now: pointer to variable which contains current time of the
203 * timers base.
204 *
205 * Allows to determine the timer latency.
206 */
9bbf98da
MD
207LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
208
209 timer_hrtimer_expire_entry,
e54456f5
MD
210
211 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
212
213 TP_ARGS(hrtimer, now),
214
215 TP_STRUCT__entry(
216 __field( void *, hrtimer )
217 __field( s64, now )
218 __field( void *, function)
219 ),
220
221 TP_fast_assign(
222 tp_assign(hrtimer, hrtimer)
223 tp_assign(now, now->tv64)
224 tp_assign(function, hrtimer->function)
225 ),
226
227 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
228 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
229)
230
9bbf98da 231LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
e54456f5
MD
232
233 TP_PROTO(struct hrtimer *hrtimer),
234
235 TP_ARGS(hrtimer),
236
237 TP_STRUCT__entry(
238 __field( void *, hrtimer )
239 ),
240
241 TP_fast_assign(
242 tp_assign(hrtimer, hrtimer)
243 ),
244
245 TP_printk("hrtimer=%p", __entry->hrtimer)
246)
247
248/**
249 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
250 * @timer: pointer to struct hrtimer
251 *
252 * When used in combination with the hrtimer_expire_entry tracepoint we can
253 * determine the runtime of the callback function.
254 */
9bbf98da
MD
255LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
256
257 timer_hrtimer_expire_exit,
e54456f5
MD
258
259 TP_PROTO(struct hrtimer *hrtimer),
260
261 TP_ARGS(hrtimer)
262)
263
264/**
265 * hrtimer_cancel - called when the hrtimer is canceled
266 * @hrtimer: pointer to struct hrtimer
267 */
9bbf98da
MD
268LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
269
270 timer_hrtimer_cancel,
e54456f5
MD
271
272 TP_PROTO(struct hrtimer *hrtimer),
273
274 TP_ARGS(hrtimer)
275)
276
277/**
278 * itimer_state - called when itimer is started or canceled
279 * @which: name of the interval timer
280 * @value: the itimers value, itimer is canceled if value->it_value is
281 * zero, otherwise it is started
282 * @expires: the itimers expiry time
283 */
9bbf98da
MD
284LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
285
286 timer_itimer_state,
e54456f5
MD
287
288 TP_PROTO(int which, const struct itimerval *const value,
289 cputime_t expires),
290
291 TP_ARGS(which, value, expires),
292
293 TP_STRUCT__entry(
294 __field( int, which )
295 __field( cputime_t, expires )
296 __field( long, value_sec )
297 __field( long, value_usec )
298 __field( long, interval_sec )
299 __field( long, interval_usec )
300 ),
301
302 TP_fast_assign(
303 tp_assign(which, which)
304 tp_assign(expires, expires)
305 tp_assign(value_sec, value->it_value.tv_sec)
306 tp_assign(value_usec, value->it_value.tv_usec)
307 tp_assign(interval_sec, value->it_interval.tv_sec)
308 tp_assign(interval_usec, value->it_interval.tv_usec)
309 ),
310
311 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
312 __entry->which, (unsigned long long)__entry->expires,
313 __entry->value_sec, __entry->value_usec,
314 __entry->interval_sec, __entry->interval_usec)
315)
316
317/**
318 * itimer_expire - called when itimer expires
319 * @which: type of the interval timer
320 * @pid: pid of the process which owns the timer
321 * @now: current time, used to calculate the latency of itimer
322 */
9bbf98da
MD
323LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
324
325 timer_itimer_expire,
e54456f5
MD
326
327 TP_PROTO(int which, struct pid *pid, cputime_t now),
328
329 TP_ARGS(which, pid, now),
330
331 TP_STRUCT__entry(
332 __field( int , which )
333 __field( pid_t, pid )
334 __field( cputime_t, now )
335 ),
336
337 TP_fast_assign(
338 tp_assign(which, which)
339 tp_assign(now, now)
340 tp_assign(pid, pid_nr(pid))
341 ),
342
343 TP_printk("which=%d pid=%d now=%llu", __entry->which,
344 (int) __entry->pid, (unsigned long long)__entry->now)
345)
346
3bc29f0a 347#endif /* LTTNG_TRACE_TIMER_H */
e54456f5
MD
348
349/* This part must be outside protection */
350#include "../../../probes/define_trace.h"
This page took 0.039972 seconds and 4 git commands to generate.