d62fd250b764fa7fb48f707700e1269c0d189a42
[lttng-modules.git] / instrumentation / events / lttng-module / timer.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM timer
3
4 #if !defined(LTTNG_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_TIMER_H
6
7 #include <probes/lttng-tracepoint-event.h>
8
9 #ifndef _TRACE_TIMER_DEF_
10 #define _TRACE_TIMER_DEF_
11 #include <linux/hrtimer.h>
12 #include <linux/timer.h>
13 #include <linux/version.h>
14
15 struct timer_list;
16
17 #endif /* _TRACE_TIMER_DEF_ */
18
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
25 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
26
27 TP_PROTO(struct timer_list *timer),
28
29 TP_ARGS(timer),
30
31 TP_FIELDS(
32 ctf_integer_hex(void *, timer, timer)
33 )
34 )
35
36 /**
37 * timer_init - called when the timer is initialized
38 * @timer: pointer to struct timer_list
39 */
40 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
41
42 TP_PROTO(struct timer_list *timer),
43
44 TP_ARGS(timer)
45 )
46
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(
62 ctf_integer_hex(void *, timer, timer)
63 ctf_integer_hex(void *, function, timer->function)
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)) */
70 /**
71 * timer_start - called when the timer is started
72 * @timer: pointer to struct timer_list
73 * @expires: the timers expiry time
74 */
75 LTTNG_TRACEPOINT_EVENT(timer_start,
76
77 TP_PROTO(struct timer_list *timer, unsigned long expires),
78
79 TP_ARGS(timer, expires),
80
81 TP_FIELDS(
82 ctf_integer_hex(void *, timer, timer)
83 ctf_integer_hex(void *, function, timer->function)
84 ctf_integer(unsigned long, expires, expires)
85 ctf_integer(unsigned long, now, jiffies)
86 )
87 )
88 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
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 */
96 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
97
98 TP_PROTO(struct timer_list *timer),
99
100 TP_ARGS(timer),
101
102 TP_FIELDS(
103 ctf_integer_hex(void *, timer, timer)
104 ctf_integer(unsigned long, now, jiffies)
105 ctf_integer_hex(void *, function, timer->function)
106 )
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 */
119 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
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 */
130 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
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 */
143 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
144
145 timer_hrtimer_init,
146
147 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
148 enum hrtimer_mode mode),
149
150 TP_ARGS(hrtimer, clockid, mode),
151
152 TP_FIELDS(
153 ctf_integer_hex(void *, hrtimer, hrtimer)
154 ctf_integer(clockid_t, clockid, clockid)
155 ctf_integer(enum hrtimer_mode, mode, mode)
156 )
157 )
158
159 /**
160 * hrtimer_start - called when the hrtimer is started
161 * @timer: pointer to struct hrtimer
162 */
163 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
164
165 timer_hrtimer_start,
166
167 TP_PROTO(struct hrtimer *hrtimer),
168
169 TP_ARGS(hrtimer),
170
171 TP_FIELDS(
172 ctf_integer_hex(void *, hrtimer, hrtimer)
173 ctf_integer_hex(void *, function, hrtimer->function)
174 ctf_integer(s64, expires,
175 lttng_ktime_get_tv64(hrtimer_get_expires(hrtimer)))
176 ctf_integer(s64, softexpires,
177 lttng_ktime_get_tv64(hrtimer_get_softexpires(hrtimer)))
178 )
179 )
180
181 /**
182 * htimmer_expire_entry - called immediately before the hrtimer callback
183 * @timer: pointer to struct hrtimer
184 * @now: pointer to variable which contains current time of the
185 * timers base.
186 *
187 * Allows to determine the timer latency.
188 */
189 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
190
191 timer_hrtimer_expire_entry,
192
193 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
194
195 TP_ARGS(hrtimer, now),
196
197 TP_FIELDS(
198 ctf_integer_hex(void *, hrtimer, hrtimer)
199 ctf_integer(s64, now, lttng_ktime_get_tv64(*now))
200 ctf_integer_hex(void *, function, hrtimer->function)
201 )
202 )
203
204 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
205
206 TP_PROTO(struct hrtimer *hrtimer),
207
208 TP_ARGS(hrtimer),
209
210 TP_FIELDS(
211 ctf_integer_hex(void *, hrtimer, hrtimer)
212 )
213 )
214
215 /**
216 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
217 * @timer: pointer to struct hrtimer
218 *
219 * When used in combination with the hrtimer_expire_entry tracepoint we can
220 * determine the runtime of the callback function.
221 */
222 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
223
224 timer_hrtimer_expire_exit,
225
226 TP_PROTO(struct hrtimer *hrtimer),
227
228 TP_ARGS(hrtimer)
229 )
230
231 /**
232 * hrtimer_cancel - called when the hrtimer is canceled
233 * @hrtimer: pointer to struct hrtimer
234 */
235 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
236
237 timer_hrtimer_cancel,
238
239 TP_PROTO(struct hrtimer *hrtimer),
240
241 TP_ARGS(hrtimer)
242 )
243
244 /**
245 * itimer_state - called when itimer is started or canceled
246 * @which: name of the interval timer
247 * @value: the itimers value, itimer is canceled if value->it_value is
248 * zero, otherwise it is started
249 * @expires: the itimers expiry time
250 */
251 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
252 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
253
254 timer_itimer_state,
255
256 TP_PROTO(int which, const struct itimerval *const value,
257 unsigned long long expires),
258
259 TP_ARGS(which, value, expires),
260
261 TP_FIELDS(
262 ctf_integer(int, which, which)
263 ctf_integer(unsigned long long, expires, expires)
264 ctf_integer(long, value_sec, value->it_value.tv_sec)
265 ctf_integer(long, value_usec, value->it_value.tv_usec)
266 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
267 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
268 )
269 )
270 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
271 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
272
273 timer_itimer_state,
274
275 TP_PROTO(int which, const struct itimerval *const value,
276 cputime_t expires),
277
278 TP_ARGS(which, value, expires),
279
280 TP_FIELDS(
281 ctf_integer(int, which, which)
282 ctf_integer(cputime_t, expires, expires)
283 ctf_integer(long, value_sec, value->it_value.tv_sec)
284 ctf_integer(long, value_usec, value->it_value.tv_usec)
285 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
286 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
287 )
288 )
289 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
290
291 /**
292 * itimer_expire - called when itimer expires
293 * @which: type of the interval timer
294 * @pid: pid of the process which owns the timer
295 * @now: current time, used to calculate the latency of itimer
296 */
297 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
298 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
299
300 timer_itimer_expire,
301
302 TP_PROTO(int which, struct pid *pid, unsigned long long now),
303
304 TP_ARGS(which, pid, now),
305
306 TP_FIELDS(
307 ctf_integer(int , which, which)
308 ctf_integer(pid_t, pid, pid_nr(pid))
309 ctf_integer(unsigned long long, now, now)
310 )
311 )
312 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
313 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
314
315 timer_itimer_expire,
316
317 TP_PROTO(int which, struct pid *pid, cputime_t now),
318
319 TP_ARGS(which, pid, now),
320
321 TP_FIELDS(
322 ctf_integer(int , which, which)
323 ctf_integer(pid_t, pid, pid_nr(pid))
324 ctf_integer(cputime_t, now, now)
325 )
326 )
327 #endif /* #else (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
328
329 #endif /* LTTNG_TRACE_TIMER_H */
330
331 /* This part must be outside protection */
332 #include <probes/define_trace.h>
This page took 0.03483 seconds and 3 git commands to generate.