Fix: timer instrumentation for 4.2 kernels
[lttng-modules.git] / instrumentation / events / lttng-module / timer.h
CommitLineData
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
3bc29f0a 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>
58397c30 13#include <linux/version.h>
3a523f5b
MD
14
15struct timer_list;
16
e54456f5
MD
17#endif /* _TRACE_TIMER_DEF_ */
18
3bc29f0a 19LTTNG_TRACEPOINT_EVENT_CLASS(timer_class,
e54456f5
MD
20
21 TP_PROTO(struct timer_list *timer),
22
23 TP_ARGS(timer),
24
f127e61e
MD
25 TP_FIELDS(
26 ctf_integer(void *, timer, timer)
27 )
e54456f5
MD
28)
29
30/**
31 * timer_init - called when the timer is initialized
32 * @timer: pointer to struct timer_list
33 */
3bc29f0a 34LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init,
e54456f5
MD
35
36 TP_PROTO(struct timer_list *timer),
37
38 TP_ARGS(timer)
39)
40
58397c30
MD
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 */
48LTTNG_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)) */
e54456f5
MD
64/**
65 * timer_start - called when the timer is started
66 * @timer: pointer to struct timer_list
67 * @expires: the timers expiry time
68 */
3bc29f0a 69LTTNG_TRACEPOINT_EVENT(timer_start,
e54456f5
MD
70
71 TP_PROTO(struct timer_list *timer, unsigned long expires),
72
73 TP_ARGS(timer, expires),
74
f127e61e
MD
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 )
e54456f5 81)
58397c30 82#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
e54456f5
MD
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 */
3bc29f0a 90LTTNG_TRACEPOINT_EVENT(timer_expire_entry,
e54456f5
MD
91
92 TP_PROTO(struct timer_list *timer),
93
94 TP_ARGS(timer),
95
f127e61e
MD
96 TP_FIELDS(
97 ctf_integer(void *, timer, timer)
98 ctf_integer(unsigned long, now, jiffies)
99 ctf_integer(void *, function, timer->function)
100 )
e54456f5
MD
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 */
3bc29f0a 113LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_expire_exit,
e54456f5
MD
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 */
3bc29f0a 124LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_cancel,
e54456f5
MD
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 */
9bbf98da
MD
137LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_init,
138
139 timer_hrtimer_init,
e54456f5
MD
140
141 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
142 enum hrtimer_mode mode),
143
144 TP_ARGS(hrtimer, clockid, mode),
145
f127e61e
MD
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 )
e54456f5
MD
151)
152
153/**
154 * hrtimer_start - called when the hrtimer is started
155 * @timer: pointer to struct hrtimer
156 */
9bbf98da
MD
157LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_start,
158
159 timer_hrtimer_start,
e54456f5
MD
160
161 TP_PROTO(struct hrtimer *hrtimer),
162
163 TP_ARGS(hrtimer),
164
f127e61e
MD
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 )
e54456f5
MD
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 */
9bbf98da
MD
181LTTNG_TRACEPOINT_EVENT_MAP(hrtimer_expire_entry,
182
183 timer_hrtimer_expire_entry,
e54456f5
MD
184
185 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
186
187 TP_ARGS(hrtimer, now),
188
f127e61e
MD
189 TP_FIELDS(
190 ctf_integer(void *, hrtimer, hrtimer)
191 ctf_integer(s64, now, now->tv64)
192 ctf_integer(void *, function, hrtimer->function)
193 )
e54456f5
MD
194)
195
9bbf98da 196LTTNG_TRACEPOINT_EVENT_CLASS(timer_hrtimer_class,
e54456f5
MD
197
198 TP_PROTO(struct hrtimer *hrtimer),
199
200 TP_ARGS(hrtimer),
201
f127e61e
MD
202 TP_FIELDS(
203 ctf_integer(void *, hrtimer, hrtimer)
204 )
e54456f5
MD
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 */
9bbf98da
MD
214LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_expire_exit,
215
216 timer_hrtimer_expire_exit,
e54456f5
MD
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 */
9bbf98da
MD
227LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(timer_hrtimer_class, hrtimer_cancel,
228
229 timer_hrtimer_cancel,
e54456f5
MD
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 */
9bbf98da
MD
243LTTNG_TRACEPOINT_EVENT_MAP(itimer_state,
244
245 timer_itimer_state,
e54456f5
MD
246
247 TP_PROTO(int which, const struct itimerval *const value,
248 cputime_t expires),
249
250 TP_ARGS(which, value, expires),
251
f127e61e
MD
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 )
e54456f5
MD
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 */
9bbf98da
MD
268LTTNG_TRACEPOINT_EVENT_MAP(itimer_expire,
269
270 timer_itimer_expire,
e54456f5
MD
271
272 TP_PROTO(int which, struct pid *pid, cputime_t now),
273
274 TP_ARGS(which, pid, now),
275
f127e61e
MD
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 )
e54456f5
MD
281)
282
3bc29f0a 283#endif /* LTTNG_TRACE_TIMER_H */
e54456f5
MD
284
285/* This part must be outside protection */
286#include "../../../probes/define_trace.h"
This page took 0.040672 seconds and 4 git commands to generate.