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