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