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