Introduce hrtimer_mode enumeration
[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 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0) || \
81 LTTNG_RHEL_KERNEL_RANGE(3,10,0,957,0,0, 3,11,0,0,0,0))
82 /**
83 * timer_start - called when the timer is started
84 * @timer: pointer to struct timer_list
85 * @expires: the timers expiry time
86 * @flags: the timers expiry time
87 */
88 LTTNG_TRACEPOINT_EVENT(timer_start,
89
90 TP_PROTO(struct timer_list *timer, unsigned long expires,
91 unsigned int flags),
92
93 TP_ARGS(timer, expires, flags),
94
95 TP_FIELDS(
96 ctf_integer_hex(void *, timer, timer)
97 ctf_integer_hex(void *, function, timer->function)
98 ctf_integer(unsigned long, expires, expires)
99 ctf_integer(unsigned long, now, jiffies)
100 ctf_integer(unsigned int, flags, flags)
101 )
102 )
103 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
104 /**
105 * timer_start - called when the timer is started
106 * @timer: pointer to struct timer_list
107 * @expires: the timers expiry time
108 */
109 LTTNG_TRACEPOINT_EVENT(timer_start,
110
111 TP_PROTO(struct timer_list *timer, unsigned long expires),
112
113 TP_ARGS(timer, expires),
114
115 TP_FIELDS(
116 ctf_integer_hex(void *, timer, timer)
117 ctf_integer_hex(void *, function, timer->function)
118 ctf_integer(unsigned long, expires, expires)
119 ctf_integer(unsigned long, now, jiffies)
120 )
121 )
122 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,2,0)) */
123
124 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \
125 LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0))
126 /**
127 * timer_expire_entry - called immediately before the timer callback
128 * @timer: pointer to struct timer_list
129 *
130 * Allows to determine the timer latency.
131 */
132 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
133
134 TP_PROTO(struct timer_list *timer, unsigned long baseclk),
135
136 TP_ARGS(timer, baseclk),
137
138 TP_FIELDS(
139 ctf_integer_hex(void *, timer, timer)
140 ctf_integer(unsigned long, now, jiffies)
141 ctf_integer_hex(void *, function, timer->function)
142 ctf_integer(unsigned long, baseclk, baseclk)
143 )
144 )
145 #else
146 /**
147 * timer_expire_entry - called immediately before the timer callback
148 * @timer: pointer to struct timer_list
149 *
150 * Allows to determine the timer latency.
151 */
152 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
153
154 TP_PROTO(struct timer_list *timer),
155
156 TP_ARGS(timer),
157
158 TP_FIELDS(
159 ctf_integer_hex(void *, timer, timer)
160 ctf_integer(unsigned long, now, jiffies)
161 ctf_integer_hex(void *, function, timer->function)
162 )
163 )
164 #endif
165
166 /**
167 * timer_expire_exit - called immediately after the timer callback returns
168 * @timer: pointer to struct timer_list
169 *
170 * When used in combination with the timer_expire_entry tracepoint we can
171 * determine the runtime of the timer callback function.
172 *
173 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
174 * be invalid. We solely track the pointer.
175 */
176 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
177
178 TP_PROTO(struct timer_list *timer),
179
180 TP_ARGS(timer)
181 )
182
183 /**
184 * timer_cancel - called when the timer is canceled
185 * @timer: pointer to struct timer_list
186 */
187 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
188
189 TP_PROTO(struct timer_list *timer),
190
191 TP_ARGS(timer)
192 )
193
194 /**
195 * hrtimer_init - called when the hrtimer is initialized
196 * @timer: pointer to struct hrtimer
197 * @clockid: the hrtimers clock
198 * @mode: the hrtimers mode
199 */
200 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
201
202 timer_hrtimer_init,
203
204 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
205 enum hrtimer_mode mode),
206
207 TP_ARGS(hrtimer, clockid, mode),
208
209 TP_FIELDS(
210 ctf_integer_hex(void *, hrtimer, hrtimer)
211 ctf_integer(clockid_t, clockid, clockid)
212 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
213 )
214 )
215
216 /**
217 * hrtimer_start - called when the hrtimer is started
218 * @timer: pointer to struct hrtimer
219 */
220 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \
221 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
222 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
223
224 timer_hrtimer_start,
225
226 TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode),
227
228 TP_ARGS(hrtimer, mode),
229
230 TP_FIELDS(
231 ctf_integer_hex(void *, hrtimer, hrtimer)
232 ctf_integer_hex(void *, function, hrtimer->function)
233 ctf_integer(s64, expires,
234 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer)))
235 ctf_integer(s64, softexpires,
236 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer)))
237 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
238 )
239 )
240 #else
241 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
242
243 timer_hrtimer_start,
244
245 TP_PROTO(struct hrtimer *hrtimer),
246
247 TP_ARGS(hrtimer),
248
249 TP_FIELDS(
250 ctf_integer_hex(void *, hrtimer, hrtimer)
251 ctf_integer_hex(void *, function, hrtimer->function)
252 ctf_integer(s64, expires,
253 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer)))
254 ctf_integer(s64, softexpires,
255 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer)))
256 )
257 )
258 #endif
259
260 /**
261 * htimmer_expire_entry - called immediately before the hrtimer callback
262 * @timer: pointer to struct hrtimer
263 * @now: pointer to variable which contains current time of the
264 * timers base.
265 *
266 * Allows to determine the timer latency.
267 */
268 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
269
270 timer_hrtimer_expire_entry,
271
272 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
273
274 TP_ARGS(hrtimer, now),
275
276 TP_FIELDS(
277 ctf_integer_hex(void *, hrtimer, hrtimer)
278 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
279 ctf_integer_hex(void *, function, hrtimer->function)
280 )
281 )
282
283 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
284
285 TP_PROTO(struct hrtimer *hrtimer),
286
287 TP_ARGS(hrtimer),
288
289 TP_FIELDS(
290 ctf_integer_hex(void *, hrtimer, hrtimer)
291 )
292 )
293
294 /**
295 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
296 * @timer: pointer to struct hrtimer
297 *
298 * When used in combination with the hrtimer_expire_entry tracepoint we can
299 * determine the runtime of the callback function.
300 */
301 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
302
303 timer_hrtimer_expire_exit,
304
305 TP_PROTO(struct hrtimer *hrtimer),
306
307 TP_ARGS(hrtimer)
308 )
309
310 /**
311 * hrtimer_cancel - called when the hrtimer is canceled
312 * @hrtimer: pointer to struct hrtimer
313 */
314 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
315
316 timer_hrtimer_cancel,
317
318 TP_PROTO(struct hrtimer *hrtimer),
319
320 TP_ARGS(hrtimer)
321 )
322
323 /**
324 * itimer_state - called when itimer is started or canceled
325 * @which: name of the interval timer
326 * @value: the itimers value, itimer is canceled if value->it_value is
327 * zero, otherwise it is started
328 * @expires: the itimers expiry time
329 */
330 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
331 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
332
333 timer_itimer_state,
334
335 TP_PROTO(int which, const struct itimerspec64 *const value,
336 unsigned long long expires),
337
338 TP_ARGS(which, value, expires),
339
340 TP_FIELDS(
341 ctf_integer(int, which, which)
342 ctf_integer(unsigned long long, expires, expires)
343 ctf_integer(long, value_sec, value->it_value.tv_sec)
344 ctf_integer(long, value_nsec, value->it_value.tv_nsec)
345 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
346 ctf_integer(long, interval_nsec, value->it_interval.tv_nsec)
347 )
348 )
349 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
350 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
351
352 timer_itimer_state,
353
354 TP_PROTO(int which, const struct itimerval *const value,
355 unsigned long long expires),
356
357 TP_ARGS(which, value, expires),
358
359 TP_FIELDS(
360 ctf_integer(int, which, which)
361 ctf_integer(unsigned long long, expires, expires)
362 ctf_integer(long, value_sec, value->it_value.tv_sec)
363 ctf_integer(long, value_usec, value->it_value.tv_usec)
364 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
365 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
366 )
367 )
368 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
369 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
370
371 timer_itimer_state,
372
373 TP_PROTO(int which, const struct itimerval *const value,
374 cputime_t expires),
375
376 TP_ARGS(which, value, expires),
377
378 TP_FIELDS(
379 ctf_integer(int, which, which)
380 ctf_integer(cputime_t, expires, expires)
381 ctf_integer(long, value_sec, value->it_value.tv_sec)
382 ctf_integer(long, value_usec, value->it_value.tv_usec)
383 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
384 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
385 )
386 )
387 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
388
389 /**
390 * itimer_expire - called when itimer expires
391 * @which: type of the interval timer
392 * @pid: pid of the process which owns the timer
393 * @now: current time, used to calculate the latency of itimer
394 */
395 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
396 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
397
398 timer_itimer_expire,
399
400 TP_PROTO(int which, struct pid *pid, unsigned long long now),
401
402 TP_ARGS(which, pid, now),
403
404 TP_FIELDS(
405 ctf_integer(int , which, which)
406 ctf_integer(pid_t, pid, pid_nr(pid))
407 ctf_integer(unsigned long long, now, now)
408 )
409 )
410 #else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
411 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
412
413 timer_itimer_expire,
414
415 TP_PROTO(int which, struct pid *pid, cputime_t now),
416
417 TP_ARGS(which, pid, now),
418
419 TP_FIELDS(
420 ctf_integer(int , which, which)
421 ctf_integer(pid_t, pid, pid_nr(pid))
422 ctf_integer(cputime_t, now, now)
423 )
424 )
425 #endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
426
427 #endif /* LTTNG_TRACE_TIMER_H */
428
429 /* This part must be outside protection */
430 #include <lttng/define_trace.h>
This page took 0.037721 seconds and 4 git commands to generate.