Support for linux kernels 2.6.32 through 2.6.37
[lttng-modules.git] / instrumentation / events / lttng-module / timer.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM timer
3
4 #if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_TIMER_H
6
7 #include <linux/tracepoint.h>
8
9 #ifndef _TRACE_TIMER_DEF_
10 #define _TRACE_TIMER_DEF_
11 #include <linux/hrtimer.h>
12 #include <linux/timer.h>
13
14 struct timer_list;
15
16 #endif /* _TRACE_TIMER_DEF_ */
17
18 DECLARE_EVENT_CLASS(timer_class,
19
20 TP_PROTO(struct timer_list *timer),
21
22 TP_ARGS(timer),
23
24 TP_STRUCT__entry(
25 __field( void *, timer )
26 ),
27
28 TP_fast_assign(
29 tp_assign(timer, timer)
30 ),
31
32 TP_printk("timer=%p", __entry->timer)
33 )
34
35 /**
36 * timer_init - called when the timer is initialized
37 * @timer: pointer to struct timer_list
38 */
39 DEFINE_EVENT(timer_class, timer_init,
40
41 TP_PROTO(struct timer_list *timer),
42
43 TP_ARGS(timer)
44 )
45
46 /**
47 * timer_start - called when the timer is started
48 * @timer: pointer to struct timer_list
49 * @expires: the timers expiry time
50 */
51 TRACE_EVENT(timer_start,
52
53 TP_PROTO(struct timer_list *timer, unsigned long expires),
54
55 TP_ARGS(timer, expires),
56
57 TP_STRUCT__entry(
58 __field( void *, timer )
59 __field( void *, function )
60 __field( unsigned long, expires )
61 __field( unsigned long, now )
62 ),
63
64 TP_fast_assign(
65 tp_assign(timer, timer)
66 tp_assign(function, timer->function)
67 tp_assign(expires, expires)
68 tp_assign(now, jiffies)
69 ),
70
71 TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
72 __entry->timer, __entry->function, __entry->expires,
73 (long)__entry->expires - __entry->now)
74 )
75
76 /**
77 * timer_expire_entry - called immediately before the timer callback
78 * @timer: pointer to struct timer_list
79 *
80 * Allows to determine the timer latency.
81 */
82 TRACE_EVENT(timer_expire_entry,
83
84 TP_PROTO(struct timer_list *timer),
85
86 TP_ARGS(timer),
87
88 TP_STRUCT__entry(
89 __field( void *, timer )
90 __field( unsigned long, now )
91 __field( void *, function)
92 ),
93
94 TP_fast_assign(
95 tp_assign(timer, timer)
96 tp_assign(now, jiffies)
97 tp_assign(function, timer->function)
98 ),
99
100 TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
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 DEFINE_EVENT(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 DEFINE_EVENT(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 TRACE_EVENT(hrtimer_init,
138
139 TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
140 enum hrtimer_mode mode),
141
142 TP_ARGS(hrtimer, clockid, mode),
143
144 TP_STRUCT__entry(
145 __field( void *, hrtimer )
146 __field( clockid_t, clockid )
147 __field( enum hrtimer_mode, mode )
148 ),
149
150 TP_fast_assign(
151 tp_assign(hrtimer, hrtimer)
152 tp_assign(clockid, clockid)
153 tp_assign(mode, mode)
154 ),
155
156 TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
157 __entry->clockid == CLOCK_REALTIME ?
158 "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
159 __entry->mode == HRTIMER_MODE_ABS ?
160 "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
161 )
162
163 /**
164 * hrtimer_start - called when the hrtimer is started
165 * @timer: pointer to struct hrtimer
166 */
167 TRACE_EVENT(hrtimer_start,
168
169 TP_PROTO(struct hrtimer *hrtimer),
170
171 TP_ARGS(hrtimer),
172
173 TP_STRUCT__entry(
174 __field( void *, hrtimer )
175 __field( void *, function )
176 __field( s64, expires )
177 __field( s64, softexpires )
178 ),
179
180 TP_fast_assign(
181 tp_assign(hrtimer, hrtimer)
182 tp_assign(function, hrtimer->function)
183 tp_assign(expires, hrtimer_get_expires(hrtimer).tv64)
184 tp_assign(softexpires, hrtimer_get_softexpires(hrtimer).tv64)
185 ),
186
187 TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
188 __entry->hrtimer, __entry->function,
189 (unsigned long long)ktime_to_ns((ktime_t) {
190 .tv64 = __entry->expires }),
191 (unsigned long long)ktime_to_ns((ktime_t) {
192 .tv64 = __entry->softexpires }))
193 )
194
195 /**
196 * htimmer_expire_entry - called immediately before the hrtimer callback
197 * @timer: pointer to struct hrtimer
198 * @now: pointer to variable which contains current time of the
199 * timers base.
200 *
201 * Allows to determine the timer latency.
202 */
203 TRACE_EVENT(hrtimer_expire_entry,
204
205 TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
206
207 TP_ARGS(hrtimer, now),
208
209 TP_STRUCT__entry(
210 __field( void *, hrtimer )
211 __field( s64, now )
212 __field( void *, function)
213 ),
214
215 TP_fast_assign(
216 tp_assign(hrtimer, hrtimer)
217 tp_assign(now, now->tv64)
218 tp_assign(function, hrtimer->function)
219 ),
220
221 TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
222 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
223 )
224
225 DECLARE_EVENT_CLASS(hrtimer_class,
226
227 TP_PROTO(struct hrtimer *hrtimer),
228
229 TP_ARGS(hrtimer),
230
231 TP_STRUCT__entry(
232 __field( void *, hrtimer )
233 ),
234
235 TP_fast_assign(
236 tp_assign(hrtimer, hrtimer)
237 ),
238
239 TP_printk("hrtimer=%p", __entry->hrtimer)
240 )
241
242 /**
243 * hrtimer_expire_exit - called immediately after the hrtimer callback returns
244 * @timer: pointer to struct hrtimer
245 *
246 * When used in combination with the hrtimer_expire_entry tracepoint we can
247 * determine the runtime of the callback function.
248 */
249 DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
250
251 TP_PROTO(struct hrtimer *hrtimer),
252
253 TP_ARGS(hrtimer)
254 )
255
256 /**
257 * hrtimer_cancel - called when the hrtimer is canceled
258 * @hrtimer: pointer to struct hrtimer
259 */
260 DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
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 */
274 TRACE_EVENT(itimer_state,
275
276 TP_PROTO(int which, const struct itimerval *const value,
277 cputime_t expires),
278
279 TP_ARGS(which, value, expires),
280
281 TP_STRUCT__entry(
282 __field( int, which )
283 __field( cputime_t, expires )
284 __field( long, value_sec )
285 __field( long, value_usec )
286 __field( long, interval_sec )
287 __field( long, interval_usec )
288 ),
289
290 TP_fast_assign(
291 tp_assign(which, which)
292 tp_assign(expires, expires)
293 tp_assign(value_sec, value->it_value.tv_sec)
294 tp_assign(value_usec, value->it_value.tv_usec)
295 tp_assign(interval_sec, value->it_interval.tv_sec)
296 tp_assign(interval_usec, value->it_interval.tv_usec)
297 ),
298
299 TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
300 __entry->which, (unsigned long long)__entry->expires,
301 __entry->value_sec, __entry->value_usec,
302 __entry->interval_sec, __entry->interval_usec)
303 )
304
305 /**
306 * itimer_expire - called when itimer expires
307 * @which: type of the interval timer
308 * @pid: pid of the process which owns the timer
309 * @now: current time, used to calculate the latency of itimer
310 */
311 TRACE_EVENT(itimer_expire,
312
313 TP_PROTO(int which, struct pid *pid, cputime_t now),
314
315 TP_ARGS(which, pid, now),
316
317 TP_STRUCT__entry(
318 __field( int , which )
319 __field( pid_t, pid )
320 __field( cputime_t, now )
321 ),
322
323 TP_fast_assign(
324 tp_assign(which, which)
325 tp_assign(now, now)
326 tp_assign(pid, pid_nr(pid))
327 ),
328
329 TP_printk("which=%d pid=%d now=%llu", __entry->which,
330 (int) __entry->pid, (unsigned long long)__entry->now)
331 )
332
333 #endif /* _TRACE_TIMER_H */
334
335 /* This part must be outside protection */
336 #include "../../../probes/define_trace.h"
This page took 0.035789 seconds and 4 git commands to generate.