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