Commit | Line | Data |
---|---|---|
f62b389e MD |
1 | #undef TRACE_SYSTEM |
2 | #define TRACE_SYSTEM sched | |
3 | ||
3bc29f0a MD |
4 | #if !defined(LTTNG_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ) |
5 | #define LTTNG_TRACE_SCHED_H | |
f62b389e | 6 | |
6ec43db8 | 7 | #include <probes/lttng-tracepoint-event.h> |
f62b389e | 8 | #include <linux/sched.h> |
7bbf55ea | 9 | #include <linux/pid_namespace.h> |
7c68b363 AG |
10 | #include <linux/binfmts.h> |
11 | #include <linux/version.h> | |
090db00e MJ |
12 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
13 | #include <linux/sched/rt.h> | |
14 | #endif | |
f62b389e | 15 | |
7bbf55ea SL |
16 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)) |
17 | #define lttng_proc_inum ns.inum | |
18 | #else | |
19 | #define lttng_proc_inum proc_inum | |
20 | #endif | |
21 | ||
22 | #define LTTNG_MAX_PID_NS_LEVEL 32 | |
23 | ||
f62b389e MD |
24 | #ifndef _TRACE_SCHED_DEF_ |
25 | #define _TRACE_SCHED_DEF_ | |
26 | ||
3ee729fe MD |
27 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) |
28 | ||
29 | static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p) | |
30 | { | |
31 | #ifdef CONFIG_SCHED_DEBUG | |
32 | BUG_ON(p != current); | |
33 | #endif /* CONFIG_SCHED_DEBUG */ | |
34 | /* | |
35 | * Preemption ignores task state, therefore preempted tasks are always RUNNING | |
36 | * (we will not have dequeued if state != RUNNING). | |
37 | */ | |
38 | return preempt ? TASK_RUNNING | TASK_STATE_MAX : p->state; | |
39 | } | |
40 | ||
41 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)) | |
857b6f4f MD |
42 | |
43 | static inline long __trace_sched_switch_state(struct task_struct *p) | |
44 | { | |
45 | long state = p->state; | |
46 | ||
47 | #ifdef CONFIG_PREEMPT | |
48 | #ifdef CONFIG_SCHED_DEBUG | |
49 | BUG_ON(p != current); | |
50 | #endif /* CONFIG_SCHED_DEBUG */ | |
51 | /* | |
52 | * For all intents and purposes a preempted task is a running task. | |
53 | */ | |
54 | if (preempt_count() & PREEMPT_ACTIVE) | |
55 | state = TASK_RUNNING | TASK_STATE_MAX; | |
56 | #endif /* CONFIG_PREEMPT */ | |
57 | ||
58 | return state; | |
59 | } | |
60 | ||
61 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) | |
33673ee7 MD |
62 | |
63 | static inline long __trace_sched_switch_state(struct task_struct *p) | |
64 | { | |
65 | long state = p->state; | |
66 | ||
67 | #ifdef CONFIG_PREEMPT | |
68 | /* | |
69 | * For all intents and purposes a preempted task is a running task. | |
70 | */ | |
71 | if (task_preempt_count(p) & PREEMPT_ACTIVE) | |
72 | state = TASK_RUNNING | TASK_STATE_MAX; | |
73 | #endif | |
74 | ||
75 | return state; | |
76 | } | |
77 | ||
78 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | |
7c68b363 | 79 | |
f62b389e MD |
80 | static inline long __trace_sched_switch_state(struct task_struct *p) |
81 | { | |
82 | long state = p->state; | |
83 | ||
84 | #ifdef CONFIG_PREEMPT | |
85 | /* | |
86 | * For all intents and purposes a preempted task is a running task. | |
87 | */ | |
88 | if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE) | |
7c68b363 | 89 | state = TASK_RUNNING | TASK_STATE_MAX; |
7c68b363 | 90 | #endif |
33673ee7 MD |
91 | |
92 | return state; | |
93 | } | |
94 | ||
95 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
96 | ||
97 | static inline long __trace_sched_switch_state(struct task_struct *p) | |
98 | { | |
99 | long state = p->state; | |
100 | ||
101 | #ifdef CONFIG_PREEMPT | |
102 | /* | |
103 | * For all intents and purposes a preempted task is a running task. | |
104 | */ | |
105 | if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE) | |
106 | state = TASK_RUNNING; | |
f62b389e MD |
107 | #endif |
108 | ||
109 | return state; | |
110 | } | |
111 | ||
7c68b363 AG |
112 | #endif |
113 | ||
f62b389e MD |
114 | #endif /* _TRACE_SCHED_DEF_ */ |
115 | ||
116 | /* | |
117 | * Tracepoint for calling kthread_stop, performed to end a kthread: | |
118 | */ | |
3bc29f0a | 119 | LTTNG_TRACEPOINT_EVENT(sched_kthread_stop, |
f62b389e MD |
120 | |
121 | TP_PROTO(struct task_struct *t), | |
122 | ||
123 | TP_ARGS(t), | |
124 | ||
f127e61e MD |
125 | TP_FIELDS( |
126 | ctf_array_text(char, comm, t->comm, TASK_COMM_LEN) | |
127 | ctf_integer(pid_t, tid, t->pid) | |
128 | ) | |
f62b389e MD |
129 | ) |
130 | ||
131 | /* | |
132 | * Tracepoint for the return value of the kthread stopping: | |
133 | */ | |
3bc29f0a | 134 | LTTNG_TRACEPOINT_EVENT(sched_kthread_stop_ret, |
f62b389e MD |
135 | |
136 | TP_PROTO(int ret), | |
137 | ||
138 | TP_ARGS(ret), | |
139 | ||
f127e61e MD |
140 | TP_FIELDS( |
141 | ctf_integer(int, ret, ret) | |
142 | ) | |
f62b389e MD |
143 | ) |
144 | ||
145 | /* | |
146 | * Tracepoint for waking up a task: | |
147 | */ | |
b6c74835 | 148 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) || \ |
f144f72a MJ |
149 | LTTNG_RT_KERNEL_RANGE(4,1,10,11, 4,2,0,0) || \ |
150 | LTTNG_RT_KERNEL_RANGE(3,18,27,26, 3,19,0,0) || \ | |
151 | LTTNG_RT_KERNEL_RANGE(3,14,61,63, 3,15,0,0) || \ | |
152 | LTTNG_RT_KERNEL_RANGE(3,12,54,73, 3,13,0,0) || \ | |
153 | LTTNG_RT_KERNEL_RANGE(3,10,97,106, 3,11,0,0) || \ | |
154 | LTTNG_RT_KERNEL_RANGE(3,4,110,139, 3,5,0,0) || \ | |
155 | LTTNG_RT_KERNEL_RANGE(3,2,77,111, 3,3,0,0)) | |
ffcf2393 MD |
156 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template, |
157 | ||
158 | TP_PROTO(struct task_struct *p), | |
159 | ||
160 | TP_ARGS(p), | |
161 | ||
162 | TP_FIELDS( | |
163 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
164 | ctf_integer(pid_t, tid, p->pid) | |
5aa835c0 | 165 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) |
ffcf2393 MD |
166 | ctf_integer(int, target_cpu, task_cpu(p)) |
167 | ) | |
168 | ) | |
169 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ | |
3bc29f0a | 170 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template, |
f62b389e | 171 | |
3a523f5b | 172 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
f62b389e MD |
173 | TP_PROTO(struct task_struct *p, int success), |
174 | ||
175 | TP_ARGS(p, success), | |
3a523f5b MD |
176 | #else |
177 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), | |
178 | ||
179 | TP_ARGS(rq, p, success), | |
180 | #endif | |
f62b389e | 181 | |
f127e61e MD |
182 | TP_FIELDS( |
183 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
184 | ctf_integer(pid_t, tid, p->pid) | |
5aa835c0 | 185 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) |
f127e61e | 186 | ctf_integer(int, success, success) |
7c68b363 | 187 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f127e61e | 188 | ctf_integer(int, target_cpu, task_cpu(p)) |
7c68b363 | 189 | #endif |
7c68b363 | 190 | ) |
f62b389e | 191 | ) |
ffcf2393 | 192 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ |
f62b389e | 193 | |
b6c74835 | 194 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) || \ |
f144f72a MJ |
195 | LTTNG_RT_KERNEL_RANGE(4,1,10,11, 4,2,0,0) || \ |
196 | LTTNG_RT_KERNEL_RANGE(3,18,27,26, 3,19,0,0) || \ | |
197 | LTTNG_RT_KERNEL_RANGE(3,14,61,63, 3,15,0,0) || \ | |
198 | LTTNG_RT_KERNEL_RANGE(3,12,54,73, 3,13,0,0) || \ | |
199 | LTTNG_RT_KERNEL_RANGE(3,10,97,106, 3,11,0,0) || \ | |
200 | LTTNG_RT_KERNEL_RANGE(3,4,110,139, 3,5,0,0) || \ | |
201 | LTTNG_RT_KERNEL_RANGE(3,2,77,111, 3,3,0,0)) | |
ffcf2393 MD |
202 | |
203 | /* | |
204 | * Tracepoint called when waking a task; this tracepoint is guaranteed to be | |
205 | * called from the waking context. | |
206 | */ | |
207 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_waking, | |
208 | TP_PROTO(struct task_struct *p), | |
209 | TP_ARGS(p)) | |
210 | ||
211 | /* | |
212 | * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG. | |
213 | * It it not always called from the waking context. | |
214 | */ | |
215 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, | |
216 | TP_PROTO(struct task_struct *p), | |
217 | TP_ARGS(p)) | |
218 | ||
219 | /* | |
220 | * Tracepoint for waking up a new task: | |
221 | */ | |
222 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, | |
223 | TP_PROTO(struct task_struct *p), | |
224 | TP_ARGS(p)) | |
225 | ||
226 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
3a523f5b | 227 | |
3bc29f0a | 228 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
f62b389e MD |
229 | TP_PROTO(struct task_struct *p, int success), |
230 | TP_ARGS(p, success)) | |
231 | ||
232 | /* | |
233 | * Tracepoint for waking up a new task: | |
234 | */ | |
3bc29f0a | 235 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
f62b389e MD |
236 | TP_PROTO(struct task_struct *p, int success), |
237 | TP_ARGS(p, success)) | |
238 | ||
3a523f5b MD |
239 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
240 | ||
3bc29f0a | 241 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
3a523f5b MD |
242 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
243 | TP_ARGS(rq, p, success)) | |
244 | ||
245 | /* | |
246 | * Tracepoint for waking up a new task: | |
247 | */ | |
3bc29f0a | 248 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
3a523f5b MD |
249 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
250 | TP_ARGS(rq, p, success)) | |
251 | ||
252 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
253 | ||
f62b389e MD |
254 | /* |
255 | * Tracepoint for task switches, performed by the scheduler: | |
256 | */ | |
3bc29f0a | 257 | LTTNG_TRACEPOINT_EVENT(sched_switch, |
f62b389e | 258 | |
3ee729fe MD |
259 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) |
260 | TP_PROTO(bool preempt, | |
261 | struct task_struct *prev, | |
262 | struct task_struct *next), | |
263 | ||
264 | TP_ARGS(preempt, prev, next), | |
265 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
f62b389e MD |
266 | TP_PROTO(struct task_struct *prev, |
267 | struct task_struct *next), | |
268 | ||
269 | TP_ARGS(prev, next), | |
3a523f5b MD |
270 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
271 | TP_PROTO(struct rq *rq, struct task_struct *prev, | |
272 | struct task_struct *next), | |
273 | ||
274 | TP_ARGS(rq, prev, next), | |
275 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e | 276 | |
f127e61e MD |
277 | TP_FIELDS( |
278 | ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN) | |
279 | ctf_integer(pid_t, prev_tid, prev->pid) | |
280 | ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO) | |
3ee729fe MD |
281 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) |
282 | ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev)) | |
283 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
f127e61e | 284 | ctf_integer(long, prev_state, __trace_sched_switch_state(prev)) |
7c68b363 | 285 | #else |
f127e61e | 286 | ctf_integer(long, prev_state, prev->state) |
7c68b363 | 287 | #endif |
f127e61e MD |
288 | ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN) |
289 | ctf_integer(pid_t, next_tid, next->pid) | |
290 | ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO) | |
291 | ) | |
f62b389e MD |
292 | ) |
293 | ||
294 | /* | |
295 | * Tracepoint for a task being migrated: | |
296 | */ | |
3bc29f0a | 297 | LTTNG_TRACEPOINT_EVENT(sched_migrate_task, |
f62b389e MD |
298 | |
299 | TP_PROTO(struct task_struct *p, int dest_cpu), | |
300 | ||
301 | TP_ARGS(p, dest_cpu), | |
302 | ||
f127e61e MD |
303 | TP_FIELDS( |
304 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
305 | ctf_integer(pid_t, tid, p->pid) | |
306 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) | |
307 | ctf_integer(int, orig_cpu, task_cpu(p)) | |
308 | ctf_integer(int, dest_cpu, dest_cpu) | |
309 | ) | |
f62b389e MD |
310 | ) |
311 | ||
3bc29f0a | 312 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_process_template, |
f62b389e MD |
313 | |
314 | TP_PROTO(struct task_struct *p), | |
315 | ||
316 | TP_ARGS(p), | |
317 | ||
f127e61e MD |
318 | TP_FIELDS( |
319 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
320 | ctf_integer(pid_t, tid, p->pid) | |
321 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) | |
322 | ) | |
f62b389e MD |
323 | ) |
324 | ||
325 | /* | |
326 | * Tracepoint for freeing a task: | |
327 | */ | |
3bc29f0a | 328 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_free, |
f62b389e MD |
329 | TP_PROTO(struct task_struct *p), |
330 | TP_ARGS(p)) | |
216b6baa | 331 | |
f62b389e MD |
332 | |
333 | /* | |
334 | * Tracepoint for a task exiting: | |
335 | */ | |
3bc29f0a | 336 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_exit, |
f62b389e MD |
337 | TP_PROTO(struct task_struct *p), |
338 | TP_ARGS(p)) | |
339 | ||
340 | /* | |
341 | * Tracepoint for waiting on task to unschedule: | |
342 | */ | |
3a523f5b | 343 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
3bc29f0a | 344 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
f62b389e MD |
345 | TP_PROTO(struct task_struct *p), |
346 | TP_ARGS(p)) | |
3a523f5b | 347 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
3bc29f0a | 348 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
3a523f5b MD |
349 | TP_PROTO(struct rq *rq, struct task_struct *p), |
350 | TP_ARGS(rq, p)) | |
351 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e MD |
352 | |
353 | /* | |
354 | * Tracepoint for a waiting task: | |
355 | */ | |
3bc29f0a | 356 | LTTNG_TRACEPOINT_EVENT(sched_process_wait, |
f62b389e MD |
357 | |
358 | TP_PROTO(struct pid *pid), | |
359 | ||
360 | TP_ARGS(pid), | |
361 | ||
f127e61e MD |
362 | TP_FIELDS( |
363 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
364 | ctf_integer(pid_t, tid, pid_nr(pid)) | |
365 | ctf_integer(int, prio, current->prio - MAX_RT_PRIO) | |
366 | ) | |
f62b389e MD |
367 | ) |
368 | ||
369 | /* | |
79b18ef7 MD |
370 | * Tracepoint for do_fork. |
371 | * Saving both TID and PID information, especially for the child, allows | |
372 | * trace analyzers to distinguish between creation of a new process and | |
373 | * creation of a new thread. Newly created processes will have child_tid | |
374 | * == child_pid, while creation of a thread yields to child_tid != | |
375 | * child_pid. | |
f62b389e | 376 | */ |
7bbf55ea | 377 | LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork, |
f62b389e MD |
378 | |
379 | TP_PROTO(struct task_struct *parent, struct task_struct *child), | |
380 | ||
381 | TP_ARGS(parent, child), | |
382 | ||
7bbf55ea SL |
383 | TP_locvar( |
384 | pid_t vtids[LTTNG_MAX_PID_NS_LEVEL]; | |
385 | unsigned int ns_level; | |
386 | ), | |
387 | ||
265822ae | 388 | TP_code_pre( |
7bbf55ea SL |
389 | if (child) { |
390 | struct pid *child_pid; | |
391 | unsigned int i; | |
392 | ||
393 | child_pid = task_pid(child); | |
394 | tp_locvar->ns_level = | |
395 | min_t(unsigned int, child_pid->level + 1, | |
396 | LTTNG_MAX_PID_NS_LEVEL); | |
397 | for (i = 0; i < tp_locvar->ns_level; i++) | |
398 | tp_locvar->vtids[i] = child_pid->numbers[i].nr; | |
399 | } | |
400 | ), | |
401 | ||
f127e61e MD |
402 | TP_FIELDS( |
403 | ctf_array_text(char, parent_comm, parent->comm, TASK_COMM_LEN) | |
404 | ctf_integer(pid_t, parent_tid, parent->pid) | |
405 | ctf_integer(pid_t, parent_pid, parent->tgid) | |
7bbf55ea SL |
406 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
407 | ctf_integer(unsigned int, parent_ns_inum, | |
408 | ({ | |
409 | unsigned int parent_ns_inum = 0; | |
410 | ||
411 | if (parent) { | |
412 | struct pid_namespace *pid_ns; | |
413 | ||
414 | pid_ns = task_active_pid_ns(parent); | |
415 | if (pid_ns) | |
416 | parent_ns_inum = | |
417 | pid_ns->lttng_proc_inum; | |
418 | } | |
419 | parent_ns_inum; | |
420 | })) | |
421 | #endif | |
f127e61e MD |
422 | ctf_array_text(char, child_comm, child->comm, TASK_COMM_LEN) |
423 | ctf_integer(pid_t, child_tid, child->pid) | |
7bbf55ea | 424 | ctf_sequence(pid_t, vtids, tp_locvar->vtids, u8, tp_locvar->ns_level) |
f127e61e | 425 | ctf_integer(pid_t, child_pid, child->tgid) |
7bbf55ea SL |
426 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
427 | ctf_integer(unsigned int, child_ns_inum, | |
428 | ({ | |
429 | unsigned int child_ns_inum = 0; | |
430 | ||
431 | if (child) { | |
432 | struct pid_namespace *pid_ns; | |
433 | ||
434 | pid_ns = task_active_pid_ns(child); | |
435 | if (pid_ns) | |
436 | child_ns_inum = | |
437 | pid_ns->lttng_proc_inum; | |
438 | } | |
439 | child_ns_inum; | |
440 | })) | |
441 | #endif | |
265822ae MD |
442 | ), |
443 | ||
444 | TP_code_post() | |
f62b389e MD |
445 | ) |
446 | ||
7c68b363 AG |
447 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) |
448 | /* | |
449 | * Tracepoint for sending a signal: | |
450 | */ | |
3bc29f0a | 451 | LTTNG_TRACEPOINT_EVENT(sched_signal_send, |
7c68b363 AG |
452 | |
453 | TP_PROTO(int sig, struct task_struct *p), | |
454 | ||
455 | TP_ARGS(sig, p), | |
456 | ||
f127e61e MD |
457 | TP_FIELDS( |
458 | ctf_integer(int, sig, sig) | |
459 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
460 | ctf_integer(pid_t, tid, p->pid) | |
461 | ) | |
7c68b363 AG |
462 | ) |
463 | #endif | |
464 | ||
c94b2508 | 465 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
46142a81 PW |
466 | /* |
467 | * Tracepoint for exec: | |
468 | */ | |
3bc29f0a | 469 | LTTNG_TRACEPOINT_EVENT(sched_process_exec, |
46142a81 PW |
470 | |
471 | TP_PROTO(struct task_struct *p, pid_t old_pid, | |
472 | struct linux_binprm *bprm), | |
473 | ||
474 | TP_ARGS(p, old_pid, bprm), | |
475 | ||
f127e61e MD |
476 | TP_FIELDS( |
477 | ctf_string(filename, bprm->filename) | |
478 | ctf_integer(pid_t, tid, p->pid) | |
479 | ctf_integer(pid_t, old_tid, old_pid) | |
480 | ) | |
46142a81 | 481 | ) |
c94b2508 | 482 | #endif |
46142a81 | 483 | |
7c68b363 | 484 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e MD |
485 | /* |
486 | * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE | |
487 | * adding sched_stat support to SCHED_FIFO/RR would be welcome. | |
488 | */ | |
3bc29f0a | 489 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_stat_template, |
f62b389e MD |
490 | |
491 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
492 | ||
493 | TP_ARGS(tsk, delay), | |
494 | ||
f127e61e MD |
495 | TP_FIELDS( |
496 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
497 | ctf_integer(pid_t, tid, tsk->pid) | |
498 | ctf_integer(u64, delay, delay) | |
f62b389e | 499 | ) |
f62b389e MD |
500 | ) |
501 | ||
502 | ||
503 | /* | |
504 | * Tracepoint for accounting wait time (time the task is runnable | |
505 | * but not actually running due to scheduler contention). | |
506 | */ | |
3bc29f0a | 507 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_wait, |
f62b389e MD |
508 | TP_PROTO(struct task_struct *tsk, u64 delay), |
509 | TP_ARGS(tsk, delay)) | |
510 | ||
511 | /* | |
512 | * Tracepoint for accounting sleep time (time the task is not runnable, | |
513 | * including iowait, see below). | |
514 | */ | |
3bc29f0a | 515 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_sleep, |
f62b389e MD |
516 | TP_PROTO(struct task_struct *tsk, u64 delay), |
517 | TP_ARGS(tsk, delay)) | |
518 | ||
519 | /* | |
520 | * Tracepoint for accounting iowait time (time the task is not runnable | |
521 | * due to waiting on IO to complete). | |
522 | */ | |
3bc29f0a | 523 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_iowait, |
f62b389e MD |
524 | TP_PROTO(struct task_struct *tsk, u64 delay), |
525 | TP_ARGS(tsk, delay)) | |
526 | ||
7c68b363 AG |
527 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
528 | /* | |
529 | * Tracepoint for accounting blocked time (time the task is in uninterruptible). | |
530 | */ | |
3bc29f0a | 531 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_blocked, |
7c68b363 AG |
532 | TP_PROTO(struct task_struct *tsk, u64 delay), |
533 | TP_ARGS(tsk, delay)) | |
534 | #endif | |
535 | ||
f62b389e MD |
536 | /* |
537 | * Tracepoint for accounting runtime (time the task is executing | |
538 | * on a CPU). | |
539 | */ | |
3bc29f0a | 540 | LTTNG_TRACEPOINT_EVENT(sched_stat_runtime, |
f62b389e MD |
541 | |
542 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), | |
543 | ||
544 | TP_ARGS(tsk, runtime, vruntime), | |
545 | ||
f127e61e MD |
546 | TP_FIELDS( |
547 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
548 | ctf_integer(pid_t, tid, tsk->pid) | |
549 | ctf_integer(u64, runtime, runtime) | |
550 | ctf_integer(u64, vruntime, vruntime) | |
f62b389e | 551 | ) |
f62b389e | 552 | ) |
7c68b363 | 553 | #endif |
f62b389e | 554 | |
0395b92c | 555 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) || \ |
959a7d80 MJ |
556 | LTTNG_RT_KERNEL_RANGE(4,9,27,18, 4,10,0,0) || \ |
557 | LTTNG_RT_KERNEL_RANGE(4,11,5,1, 4,12,0,0)) | |
35970083 MJ |
558 | /* |
559 | * Tracepoint for showing priority inheritance modifying a tasks | |
560 | * priority. | |
561 | */ | |
562 | LTTNG_TRACEPOINT_EVENT(sched_pi_setprio, | |
563 | ||
564 | TP_PROTO(struct task_struct *tsk, struct task_struct *pi_task), | |
565 | ||
566 | TP_ARGS(tsk, pi_task), | |
567 | ||
568 | TP_FIELDS( | |
569 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
570 | ctf_integer(pid_t, tid, tsk->pid) | |
571 | ctf_integer(int, oldprio, tsk->prio - MAX_RT_PRIO) | |
572 | ctf_integer(int, newprio, pi_task ? pi_task->prio - MAX_RT_PRIO : tsk->prio - MAX_RT_PRIO) | |
573 | ) | |
574 | ) | |
575 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) | |
f62b389e MD |
576 | /* |
577 | * Tracepoint for showing priority inheritance modifying a tasks | |
578 | * priority. | |
579 | */ | |
3bc29f0a | 580 | LTTNG_TRACEPOINT_EVENT(sched_pi_setprio, |
f62b389e MD |
581 | |
582 | TP_PROTO(struct task_struct *tsk, int newprio), | |
583 | ||
584 | TP_ARGS(tsk, newprio), | |
585 | ||
f127e61e MD |
586 | TP_FIELDS( |
587 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
588 | ctf_integer(pid_t, tid, tsk->pid) | |
589 | ctf_integer(int, oldprio, tsk->prio - MAX_RT_PRIO) | |
590 | ctf_integer(int, newprio, newprio - MAX_RT_PRIO) | |
591 | ) | |
f62b389e | 592 | ) |
7c68b363 | 593 | #endif |
f62b389e | 594 | |
3bc29f0a | 595 | #endif /* LTTNG_TRACE_SCHED_H */ |
f62b389e MD |
596 | |
597 | /* This part must be outside protection */ | |
6ec43db8 | 598 | #include <probes/define_trace.h> |