Commit | Line | Data |
---|---|---|
9f36eaed | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
e54456f5 MD |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM timer | |
4 | ||
3bc29f0a MD |
5 | #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_TIMER_H | |
e54456f5 | 7 | |
6ec43db8 | 8 | #include <probes/lttng-tracepoint-event.h> |
e54456f5 MD |
9 | |
10 | #ifndef _TRACE_TIMER_DEF_ | |
11 | #define _TRACE_TIMER_DEF_ | |
12 | #include <linux/hrtimer.h> | |
13 | #include <linux/timer.h> | |
32328e6c | 14 | #include <linux/version.h> |
3a523f5b MD |
15 | |
16 | struct timer_list; | |
17 | ||
e54456f5 MD |
18 | #endif /* _TRACE_TIMER_DEF_ */ |
19 | ||
507143bc MD |
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 | ||
3bc29f0a | 26 | LTTNG_TRACEPOINT_EVENT_CLASS(timer_class, |
e54456f5 MD |
27 | |
28 | TP_PROTO(struct timer_list *timer), | |
29 | ||
30 | TP_ARGS(timer), | |
31 | ||
f127e61e | 32 | TP_FIELDS( |
fa91fcac | 33 | ctf_integer_hex(void *, timer, timer) |
f127e61e | 34 | ) |
e54456f5 MD |
35 | ) |
36 | ||
37 | /** | |
38 | * timer_init - called when the timer is initialized | |
39 | * @timer: pointer to struct timer_list | |
40 | */ | |
3bc29f0a | 41 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init, |
e54456f5 MD |
42 | |
43 | TP_PROTO(struct timer_list *timer), | |
44 | ||
45 | TP_ARGS(timer) | |
46 | ) | |
47 | ||
32328e6c MD |
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( | |
fa91fcac MD |
63 | ctf_integer_hex(void *, timer, timer) |
64 | ctf_integer_hex(void *, function, timer->function) | |
32328e6c MD |
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)) */ | |
e54456f5 MD |
71 | /** |
72 | * timer_start - called when the timer is started | |
73 | * @timer: pointer to struct timer_list | |
74 | * @expires: the timers expiry time | |
75 | */ | |
3bc29f0a | 76 | LTTNG_TRACEPOINT_EVENT(timer_start, |
e54456f5 MD |
77 | |
78 | TP_PROTO(struct timer_list *timer, unsigned long expires), | |
79 | ||
80 | TP_ARGS(timer, expires), | |
81 | ||
f127e61e | 82 | TP_FIELDS( |
fa91fcac MD |
83 | ctf_integer_hex(void *, timer, timer) |
84 | ctf_integer_hex(void *, function, timer->function) | |
f127e61e MD |
85 | ctf_integer(unsigned long, expires, expires) |
86 | ctf_integer(unsigned long, now, jiffies) | |
87 | ) | |
e54456f5 | 88 | ) |
32328e6c | 89 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */ |
e54456f5 MD |
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 | */ | |
3bc29f0a | 97 | LTTNG_TRACEPOINT_EVENT(timer_expire_entry, |
e54456f5 MD |
98 | |
99 | TP_PROTO(struct timer_list *timer), | |
100 | ||
101 | TP_ARGS(timer), | |
102 | ||
f127e61e | 103 | TP_FIELDS( |
fa91fcac | 104 | ctf_integer_hex(void *, timer, timer) |
f127e61e | 105 | ctf_integer(unsigned long, now, jiffies) |
fa91fcac | 106 | ctf_integer_hex(void *, function, timer->function) |
f127e61e | 107 | ) |
e54456f5 MD |
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 | */ | |
3bc29f0a | 120 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit, |
e54456f5 MD |
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 | */ | |
3bc29f0a | 131 | LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel, |
e54456f5 MD |
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 | */ | |
9bbf98da MD |
144 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init, |
145 | ||
146 | timer_hrtimer_init, | |
e54456f5 MD |
147 | |
148 | TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid, | |
149 | enum hrtimer_mode mode), | |
150 | ||
151 | TP_ARGS(hrtimer, clockid, mode), | |
152 | ||
f127e61e | 153 | TP_FIELDS( |
fa91fcac | 154 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e MD |
155 | ctf_integer(clockid_t, clockid, clockid) |
156 | ctf_integer(enum hrtimer_mode, mode, mode) | |
157 | ) | |
e54456f5 MD |
158 | ) |
159 | ||
160 | /** | |
161 | * hrtimer_start - called when the hrtimer is started | |
162 | * @timer: pointer to struct hrtimer | |
163 | */ | |
562860aa RV |
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 | |
9bbf98da MD |
185 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start, |
186 | ||
187 | timer_hrtimer_start, | |
e54456f5 MD |
188 | |
189 | TP_PROTO(struct hrtimer *hrtimer), | |
190 | ||
191 | TP_ARGS(hrtimer), | |
192 | ||
f127e61e | 193 | TP_FIELDS( |
fa91fcac MD |
194 | ctf_integer_hex(void *, hrtimer, hrtimer) |
195 | ctf_integer_hex(void *, function, hrtimer->function) | |
507143bc MD |
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))) | |
f127e61e | 200 | ) |
e54456f5 | 201 | ) |
562860aa | 202 | #endif |
e54456f5 MD |
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 | */ | |
9bbf98da MD |
212 | LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry, |
213 | ||
214 | timer_hrtimer_expire_entry, | |
e54456f5 MD |
215 | |
216 | TP_PROTO(struct hrtimer *hrtimer, ktime_t *now), | |
217 | ||
218 | TP_ARGS(hrtimer, now), | |
219 | ||
f127e61e | 220 | TP_FIELDS( |
fa91fcac | 221 | ctf_integer_hex(void *, hrtimer, hrtimer) |
507143bc | 222 | ctf_integer(s64, now, lttng_ktime_get_tv64(*now)) |
fa91fcac | 223 | ctf_integer_hex(void *, function, hrtimer->function) |
f127e61e | 224 | ) |
e54456f5 MD |
225 | ) |
226 | ||
9bbf98da | 227 | LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class, |
e54456f5 MD |
228 | |
229 | TP_PROTO(struct hrtimer *hrtimer), | |
230 | ||
231 | TP_ARGS(hrtimer), | |
232 | ||
f127e61e | 233 | TP_FIELDS( |
fa91fcac | 234 | ctf_integer_hex(void *, hrtimer, hrtimer) |
f127e61e | 235 | ) |
e54456f5 MD |
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 | */ | |
9bbf98da MD |
245 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit, |
246 | ||
247 | timer_hrtimer_expire_exit, | |
e54456f5 MD |
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 | */ | |
9bbf98da MD |
258 | LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel, |
259 | ||
260 | timer_hrtimer_cancel, | |
e54456f5 MD |
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 | */ | |
678dd1c8 FD |
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)) */ | |
9bbf98da MD |
294 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_state, |
295 | ||
296 | timer_itimer_state, | |
e54456f5 MD |
297 | |
298 | TP_PROTO(int which, const struct itimerval *const value, | |
299 | cputime_t expires), | |
300 | ||
301 | TP_ARGS(which, value, expires), | |
302 | ||
f127e61e MD |
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 | ) | |
e54456f5 | 311 | ) |
678dd1c8 | 312 | #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ |
e54456f5 MD |
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 | */ | |
678dd1c8 FD |
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)) */ | |
9bbf98da MD |
336 | LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire, |
337 | ||
338 | timer_itimer_expire, | |
e54456f5 MD |
339 | |
340 | TP_PROTO(int which, struct pid *pid, cputime_t now), | |
341 | ||
342 | TP_ARGS(which, pid, now), | |
343 | ||
f127e61e MD |
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 | ) | |
e54456f5 | 349 | ) |
678dd1c8 | 350 | #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ |
e54456f5 | 351 | |
3bc29f0a | 352 | #endif /* LTTNG_TRACE_TIMER_H */ |
e54456f5 MD |
353 | |
354 | /* This part must be outside protection */ | |
6ec43db8 | 355 | #include <probes/define_trace.h> |