8703ea0b89b4c50405388d3944d4d67c1695e7e6
[lttng-modules.git] / instrumentation / events / lttng-module / timer.h
1 /* SPDX-License-Identifier: GPL-2.0 */
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 /**
93 * timer_expire_entry - called immediately before the timer callback
94 * @timer: pointer to struct timer_list
95 *
96 * Allows to determine the timer latency.
97 */
98 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
99
100 TP_PROTO(struct timer_list *timer),
101
102 TP_ARGS(timer),
103
104 TP_FIELDS(
105 ctf_integer_hex(void *, timer, timer)
106 ctf_integer(unsigned long, now, jiffies)
107 ctf_integer_hex(void *, function, timer->function)
108 )
109 )
110
111 /**
112 * timer_expire_exit - called immediately after the timer callback returns
113 * @timer: pointer to struct timer_list
114 *
115 * When used in combination with the timer_expire_entry tracepoint we can
116 * determine the runtime of the timer callback function.
117 *
118 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
119 * be invalid. We solely track the pointer.
120 */
121 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
122
123 TP_PROTO(struct timer_list *timer),
124
125 TP_ARGS(timer)
126 )
127
128 /**
129 * timer_cancel - called when the timer is canceled
130 * @timer: pointer to struct timer_list
131 */
132 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
133
134 TP_PROTO(struct timer_list *timer),
135
136 TP_ARGS(timer)
137 )
138
139 /**
140 * hrtimer_init - called when the hrtimer is initialized
141 * @timer: pointer to struct hrtimer
142 * @clockid: the hrtimers clock
143 * @mode: the hrtimers mode
144 */
145 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
146
147 timer_hrtimer_init,
148
149 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
150 enum hrtimer_mode mode),
151
152 TP_ARGS(hrtimer, clockid, mode),
153
154 TP_FIELDS(
155 ctf_integer_hex(void *, hrtimer, hrtimer)
156 ctf_integer(clockid_t, clockid, clockid)
157 ctf_integer(enum hrtimer_mode, mode, mode)
158 )
159 )
160
161 /**
162 * hrtimer_start - called when the hrtimer is started
163 * @timer: pointer to struct hrtimer
164 */
165 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,16,0) || \
166 LTTNG_RT_KERNEL_RANGE(4,14,0,0, 4,15,0,0))
167 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
168
169 timer_hrtimer_start,
170
171 TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode),
172
173 TP_ARGS(hrtimer, mode),
174
175 TP_FIELDS(
176 ctf_integer_hex(void *, hrtimer, hrtimer)
177 ctf_integer_hex(void *, function, hrtimer->function)
178 ctf_integer(s64, expires,
179 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer)))
180 ctf_integer(s64, softexpires,
181 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer)))
182 ctf_integer(enum hrtimer_mode, mode, mode)
183 )
184 )
185 #else
186 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
187
188 timer_hrtimer_start,
189
190 TP_PROTO(struct hrtimer *hrtimer),
191
192 TP_ARGS(hrtimer),
193
194 TP_FIELDS(
195 ctf_integer_hex(void *, hrtimer, hrtimer)
196 ctf_integer_hex(void *, function, hrtimer->function)
197 ctf_integer(s64, expires,
198 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer)))
199 ctf_integer(s64, softexpires,
200 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer)))
201 )
202 )
203 #endif
204
205 /**
206 * htimmer_expire_entry - called immediately before the hrtimer callback
207 * @timer: pointer to struct hrtimer
208 * @now: pointer to variable which contains current time of the
209 * timers base.
210 *
211 * Allows to determine the timer latency.
212 */
213 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
214
215 timer_hrtimer_expire_entry,
216
217 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
218
219 TP_ARGS(hrtimer, now),
220
221 TP_FIELDS(
222 ctf_integer_hex(void *, hrtimer, hrtimer)
223 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
224 ctf_integer_hex(void *, function, hrtimer->function)
225 )
226 )
227
228 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
229
230 TP_PROTO(struct hrtimer *hrtimer),
231
232 TP_ARGS(hrtimer),
233
234 TP_FIELDS(
235 ctf_integer_hex(void *, hrtimer, hrtimer)
236 )
237 )
238
239 /**
240 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
241 * @timer: pointer to struct hrtimer
242 *
243 * When used in combination with the hrtimer_expire_entry tracepoint we can
244 * determine the runtime of the callback function.
245 */
246 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
247
248 timer_hrtimer_expire_exit,
249
250 TP_PROTO(struct hrtimer *hrtimer),
251
252 TP_ARGS(hrtimer)
253 )
254
255 /**
256 * hrtimer_cancel - called when the hrtimer is canceled
257 * @hrtimer: pointer to struct hrtimer
258 */
259 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
260
261 timer_hrtimer_cancel,
262
263 TP_PROTO(struct hrtimer *hrtimer),
264
265 TP_ARGS(hrtimer)
266 )
267
268 /**
269 * itimer_state - called when itimer is started or canceled
270 * @which: name of the interval timer
271 * @value: the itimers value, itimer is canceled if value->it_value is
272 * zero, otherwise it is started
273 * @expires: the itimers expiry time
274 */
275 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
276 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
277
278 timer_itimer_state,
279
280 TP_PROTO(int which, const struct itimerval *const value,
281 unsigned long long expires),
282
283 TP_ARGS(which, value, expires),
284
285 TP_FIELDS(
286 ctf_integer(int, which, which)
287 ctf_integer(unsigned long long, expires, expires)
288 ctf_integer(long, value_sec, value->it_value.tv_sec)
289 ctf_integer(long, value_usec, value->it_value.tv_usec)
290 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
291 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
292 )
293 )
294 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
295 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
296
297 timer_itimer_state,
298
299 TP_PROTO(int which, const struct itimerval *const value,
300 cputime_t expires),
301
302 TP_ARGS(which, value, expires),
303
304 TP_FIELDS(
305 ctf_integer(int, which, which)
306 ctf_integer(cputime_t, expires, expires)
307 ctf_integer(long, value_sec, value->it_value.tv_sec)
308 ctf_integer(long, value_usec, value->it_value.tv_usec)
309 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
310 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
311 )
312 )
313 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
314
315 /**
316 * itimer_expire - called when itimer expires
317 * @which: type of the interval timer
318 * @pid: pid of the process which owns the timer
319 * @now: current time, used to calculate the latency of itimer
320 */
321 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
322 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
323
324 timer_itimer_expire,
325
326 TP_PROTO(int which, struct pid *pid, unsigned long long now),
327
328 TP_ARGS(which, pid, now),
329
330 TP_FIELDS(
331 ctf_integer(int , which, which)
332 ctf_integer(pid_t, pid, pid_nr(pid))
333 ctf_integer(unsigned long long, now, now)
334 )
335 )
336 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
337 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
338
339 timer_itimer_expire,
340
341 TP_PROTO(int which, struct pid *pid, cputime_t now),
342
343 TP_ARGS(which, pid, now),
344
345 TP_FIELDS(
346 ctf_integer(int , which, which)
347 ctf_integer(pid_t, pid, pid_nr(pid))
348 ctf_integer(cputime_t, now, now)
349 )
350 )
351 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
352
353 #endif /* LTTNG_TRACE_TIMER_H */
354
355 /* This part must be outside protection */
356 #include <probes/define_trace.h>
This page took 0.036388 seconds and 3 git commands to generate.