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