Fix: scsi: sd: Atomic write support added in 6.11-rc1
[lttng-modules.git] / include / instrumentation / events / timer.h
CommitLineData
61baff6e
MJ
1// SPDX-FileCopyrightText: 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
e54456f5
MD
5#undef TRACE_SYSTEM
6#define TRACE_SYSTEM timer
7
3bc29f0a
MD
8#if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
9#define LTTNG_TRACE_TIMER_H
e54456f5 10
3b4aafcb 11#include <lttng/tracepoint-event.h>
e54456f5
MD
12
13#ifndef _TRACE_TIMER_DEF_
14#define _TRACE_TIMER_DEF_
15#include <linux/hrtimer.h>
16#include <linux/timer.h>
5f4c791e 17#include <lttng/kernel-version.h>
3a523f5b
MD
18
19struct timer_list;
20
e54456f5
MD
21#endif /* _TRACE_TIMER_DEF_ */
22
9f5c9fe5
MD
23LTTNG_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
5f4c791e 55#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
507143bc 56#define lttng_ktime_get_tv64(kt) (kt)
5f4c791e 57#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
507143bc 58#define lttng_ktime_get_tv64(kt) ((kt).tv64)
5f4c791e 59#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
507143bc 60
3bc29f0a 61LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
e54456f5
MD
62
63 TP_PROTO(struct timer_list *timer),
64
65 TP_ARGS(timer),
66
f127e61e 67 TP_FIELDS(
fa91fcac 68 ctf_integer_hex(void *, timer, timer)
f127e61e 69 )
e54456f5
MD
70)
71
72/**
73 * timer_init - called when the timer is initialized
74 * @timer: pointer to struct timer_list
75 */
3bc29f0a 76LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
e54456f5
MD
77
78 TP_PROTO(struct timer_list *timer),
79
80 TP_ARGS(timer)
81)
82
f97f9d2e
KS
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))
64d3007b
KS
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 */
91LTTNG_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
32328e6c
MD
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 */
113LTTNG_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(
fa91fcac
MD
121 ctf_integer_hex(void *, timer, timer)
122 ctf_integer_hex(void *, function, timer->function)
32328e6c
MD
123 ctf_integer(unsigned long, expires, expires)
124 ctf_integer(unsigned long, now, jiffies)
125 ctf_integer(unsigned int, flags, flags)
126 )
127)
64d3007b 128#endif
e54456f5 129
05355f0b 130#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0) || \
fb4b9097 131 LTTNG_KERNEL_RANGE(4,19,312, 4,20,0) || \
05355f0b 132 LTTNG_RHEL_KERNEL_RANGE(4,18,0,193,0,0, 4,19,0,0,0,0))
d88e2fe5
MJ
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 */
139LTTNG_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
e54456f5
MD
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 */
3bc29f0a 159LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
e54456f5
MD
160
161 TP_PROTO(struct timer_list *timer),
162
163 TP_ARGS(timer),
164
f127e61e 165 TP_FIELDS(
fa91fcac 166 ctf_integer_hex(void *, timer, timer)
f127e61e 167 ctf_integer(unsigned long, now, jiffies)
fa91fcac 168 ctf_integer_hex(void *, function, timer->function)
f127e61e 169 )
e54456f5 170)
d88e2fe5 171#endif
e54456f5
MD
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 */
3bc29f0a 183LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
e54456f5
MD
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 */
3bc29f0a 194LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
e54456f5
MD
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 */
9bbf98da
MD
207LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
208
209 timer_hrtimer_init,
e54456f5
MD
210
211 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
212 enum hrtimer_mode mode),
213
214 TP_ARGS(hrtimer, clockid, mode),
215
f127e61e 216 TP_FIELDS(
fa91fcac 217 ctf_integer_hex(void *, hrtimer, hrtimer)
f127e61e 218 ctf_integer(clockid_t, clockid, clockid)
9f5c9fe5 219 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
f127e61e 220 )
e54456f5
MD
221)
222
223/**
224 * hrtimer_start - called when the hrtimer is started
225 * @timer: pointer to struct hrtimer
226 */
5f4c791e 227#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,16,0) || \
562860aa
RV
228 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
229LTTNG_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)))
9f5c9fe5 244 ctf_enum(hrtimer_mode, unsigned int, mode, mode)
562860aa
RV
245 )
246)
247#else
9bbf98da
MD
248LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
249
250 timer_hrtimer_start,
e54456f5
MD
251
252 TP_PROTO(struct hrtimer *hrtimer),
253
254 TP_ARGS(hrtimer),
255
f127e61e 256 TP_FIELDS(
fa91fcac
MD
257 ctf_integer_hex(void *, hrtimer, hrtimer)
258 ctf_integer_hex(void *, function, hrtimer->function)
507143bc
MD
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)))
f127e61e 263 )
e54456f5 264)
562860aa 265#endif
e54456f5
MD
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 */
9bbf98da
MD
275LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
276
277 timer_hrtimer_expire_entry,
e54456f5
MD
278
279 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
280
281 TP_ARGS(hrtimer, now),
282
f127e61e 283 TP_FIELDS(
fa91fcac 284 ctf_integer_hex(void *, hrtimer, hrtimer)
507143bc 285 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
fa91fcac 286 ctf_integer_hex(void *, function, hrtimer->function)
f127e61e 287 )
e54456f5
MD
288)
289
9bbf98da 290LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
e54456f5
MD
291
292 TP_PROTO(struct hrtimer *hrtimer),
293
294 TP_ARGS(hrtimer),
295
f127e61e 296 TP_FIELDS(
fa91fcac 297 ctf_integer_hex(void *, hrtimer, hrtimer)
f127e61e 298 )
e54456f5
MD
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 */
9bbf98da
MD
308LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
309
310 timer_hrtimer_expire_exit,
e54456f5
MD
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 */
9bbf98da
MD
321LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
322
323 timer_hrtimer_cancel,
e54456f5
MD
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 */
5f4c791e 337#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
7c1dd120
MJ
338LTTNG_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)
5f4c791e 356#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
678dd1c8
FD
357LTTNG_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)
5f4c791e 375#else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
9bbf98da
MD
376LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
377
378 timer_itimer_state,
e54456f5
MD
379
380 TP_PROTO(int which, const struct itimerval *const value,
381 cputime_t expires),
382
383 TP_ARGS(which, value, expires),
384
f127e61e
MD
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 )
e54456f5 393)
5f4c791e 394#endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
e54456f5
MD
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 */
5f4c791e 402#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
678dd1c8
FD
403LTTNG_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)
5f4c791e 417#else /* if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
9bbf98da
MD
418LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
419
420 timer_itimer_expire,
e54456f5
MD
421
422 TP_PROTO(int which, struct pid *pid, cputime_t now),
423
424 TP_ARGS(which, pid, now),
425
f127e61e
MD
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 )
e54456f5 431)
5f4c791e 432#endif /* #else (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
e54456f5 433
3bc29f0a 434#endif /* LTTNG_TRACE_TIMER_H */
e54456f5
MD
435
436/* This part must be outside protection */
3b4aafcb 437#include <lttng/define_trace.h>
This page took 0.1301 seconds and 5 git commands to generate.