Fix: timer instrumentation for 4.2 kernels
[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 LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
20
21 TP_PROTO(struct timer_list *timer),
22
23 TP_ARGS(timer),
24
25 TP_FIELDS(
26 ctf_integer(void *, timer, timer)
27 )
28 )
29
30 /**
31 * timer_init - called when the timer is initialized
32 * @timer: pointer to struct timer_list
33 */
34 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
35
36 TP_PROTO(struct timer_list *timer),
37
38 TP_ARGS(timer)
39 )
40
41 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0))
42 /**
43 * timer_start - called when the timer is started
44 * @timer: pointer to struct timer_list
45 * @expires: the timers expiry time
46 * @flags: the timers expiry time
47 */
48 LTTNG_TRACEPOINT_EVENT(timer_start,
49
50 TP_PROTO(struct timer_list *timer, unsigned long expires,
51 unsigned int flags),
52
53 TP_ARGS(timer, expires, flags),
54
55 TP_FIELDS(
56 ctf_integer(void *, timer, timer)
57 ctf_integer(void *, function, timer->function)
58 ctf_integer(unsigned long, expires, expires)
59 ctf_integer(unsigned long, now, jiffies)
60 ctf_integer(unsigned int, flags, flags)
61 )
62 )
63 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
64 /**
65 * timer_start - called when the timer is started
66 * @timer: pointer to struct timer_list
67 * @expires: the timers expiry time
68 */
69 LTTNG_TRACEPOINT_EVENT(timer_start,
70
71 TP_PROTO(struct timer_list *timer, unsigned long expires),
72
73 TP_ARGS(timer, expires),
74
75 TP_FIELDS(
76 ctf_integer(void *, timer, timer)
77 ctf_integer(void *, function, timer->function)
78 ctf_integer(unsigned long, expires, expires)
79 ctf_integer(unsigned long, now, jiffies)
80 )
81 )
82 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
83
84 /**
85 * timer_expire_entry - called immediately before the timer callback
86 * @timer: pointer to struct timer_list
87 *
88 * Allows to determine the timer latency.
89 */
90 LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
91
92 TP_PROTO(struct timer_list *timer),
93
94 TP_ARGS(timer),
95
96 TP_FIELDS(
97 ctf_integer(void *, timer, timer)
98 ctf_integer(unsigned long, now, jiffies)
99 ctf_integer(void *, function, timer->function)
100 )
101 )
102
103 /**
104 * timer_expire_exit - called immediately after the timer callback returns
105 * @timer: pointer to struct timer_list
106 *
107 * When used in combination with the timer_expire_entry tracepoint we can
108 * determine the runtime of the timer callback function.
109 *
110 * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
111 * be invalid. We solely track the pointer.
112 */
113 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
114
115 TP_PROTO(struct timer_list *timer),
116
117 TP_ARGS(timer)
118 )
119
120 /**
121 * timer_cancel - called when the timer is canceled
122 * @timer: pointer to struct timer_list
123 */
124 LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
125
126 TP_PROTO(struct timer_list *timer),
127
128 TP_ARGS(timer)
129 )
130
131 /**
132 * hrtimer_init - called when the hrtimer is initialized
133 * @timer: pointer to struct hrtimer
134 * @clockid: the hrtimers clock
135 * @mode: the hrtimers mode
136 */
137 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
138
139 timer_hrtimer_init,
140
141 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
142 enum hrtimer_mode mode),
143
144 TP_ARGS(hrtimer, clockid, mode),
145
146 TP_FIELDS(
147 ctf_integer(void *, hrtimer, hrtimer)
148 ctf_integer(clockid_t, clockid, clockid)
149 ctf_integer(enum hrtimer_mode, mode, mode)
150 )
151 )
152
153 /**
154 * hrtimer_start - called when the hrtimer is started
155 * @timer: pointer to struct hrtimer
156 */
157 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
158
159 timer_hrtimer_start,
160
161 TP_PROTO(struct hrtimer *hrtimer),
162
163 TP_ARGS(hrtimer),
164
165 TP_FIELDS(
166 ctf_integer(void *, hrtimer, hrtimer)
167 ctf_integer(void *, function, hrtimer->function)
168 ctf_integer(s64, expires, hrtimer_get_expires(hrtimer).tv64)
169 ctf_integer(s64, softexpires, hrtimer_get_softexpires(hrtimer).tv64)
170 )
171 )
172
173 /**
174 * htimmer_expire_entry - called immediately before the hrtimer callback
175 * @timer: pointer to struct hrtimer
176 * @now: pointer to variable which contains current time of the
177 * timers base.
178 *
179 * Allows to determine the timer latency.
180 */
181 LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
182
183 timer_hrtimer_expire_entry,
184
185 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
186
187 TP_ARGS(hrtimer, now),
188
189 TP_FIELDS(
190 ctf_integer(void *, hrtimer, hrtimer)
191 ctf_integer(s64, now, now->tv64)
192 ctf_integer(void *, function, hrtimer->function)
193 )
194 )
195
196 LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
197
198 TP_PROTO(struct hrtimer *hrtimer),
199
200 TP_ARGS(hrtimer),
201
202 TP_FIELDS(
203 ctf_integer(void *, hrtimer, hrtimer)
204 )
205 )
206
207 /**
208 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
209 * @timer: pointer to struct hrtimer
210 *
211 * When used in combination with the hrtimer_expire_entry tracepoint we can
212 * determine the runtime of the callback function.
213 */
214 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
215
216 timer_hrtimer_expire_exit,
217
218 TP_PROTO(struct hrtimer *hrtimer),
219
220 TP_ARGS(hrtimer)
221 )
222
223 /**
224 * hrtimer_cancel - called when the hrtimer is canceled
225 * @hrtimer: pointer to struct hrtimer
226 */
227 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
228
229 timer_hrtimer_cancel,
230
231 TP_PROTO(struct hrtimer *hrtimer),
232
233 TP_ARGS(hrtimer)
234 )
235
236 /**
237 * itimer_state - called when itimer is started or canceled
238 * @which: name of the interval timer
239 * @value: the itimers value, itimer is canceled if value->it_value is
240 * zero, otherwise it is started
241 * @expires: the itimers expiry time
242 */
243 LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
244
245 timer_itimer_state,
246
247 TP_PROTO(int which, const struct itimerval *const value,
248 cputime_t expires),
249
250 TP_ARGS(which, value, expires),
251
252 TP_FIELDS(
253 ctf_integer(int, which, which)
254 ctf_integer(cputime_t, expires, expires)
255 ctf_integer(long, value_sec, value->it_value.tv_sec)
256 ctf_integer(long, value_usec, value->it_value.tv_usec)
257 ctf_integer(long, interval_sec, value->it_interval.tv_sec)
258 ctf_integer(long, interval_usec, value->it_interval.tv_usec)
259 )
260 )
261
262 /**
263 * itimer_expire - called when itimer expires
264 * @which: type of the interval timer
265 * @pid: pid of the process which owns the timer
266 * @now: current time, used to calculate the latency of itimer
267 */
268 LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
269
270 timer_itimer_expire,
271
272 TP_PROTO(int which, struct pid *pid, cputime_t now),
273
274 TP_ARGS(which, pid, now),
275
276 TP_FIELDS(
277 ctf_integer(int , which, which)
278 ctf_integer(pid_t, pid, pid_nr(pid))
279 ctf_integer(cputime_t, now, now)
280 )
281 )
282
283 #endif /* LTTNG_TRACE_TIMER_H */
284
285 /* This part must be outside protection */
286 #include "../../../probes/define_trace.h"
This page took 0.049183 seconds and 5 git commands to generate.