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