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