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