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