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 | |
3bc29f0a | 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 | */ | |
ffcf2393 MD |
148 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) |
149 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template, | |
150 | ||
151 | TP_PROTO(struct task_struct *p), | |
152 | ||
153 | TP_ARGS(p), | |
154 | ||
155 | TP_FIELDS( | |
156 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
157 | ctf_integer(pid_t, tid, p->pid) | |
5aa835c0 | 158 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) |
ffcf2393 MD |
159 | ctf_integer(int, target_cpu, task_cpu(p)) |
160 | ) | |
161 | ) | |
162 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ | |
3bc29f0a | 163 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_wakeup_template, |
f62b389e | 164 | |
3a523f5b | 165 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
f62b389e MD |
166 | TP_PROTO(struct task_struct *p, int success), |
167 | ||
168 | TP_ARGS(p, success), | |
3a523f5b MD |
169 | #else |
170 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), | |
171 | ||
172 | TP_ARGS(rq, p, success), | |
173 | #endif | |
f62b389e | 174 | |
f127e61e MD |
175 | TP_FIELDS( |
176 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
177 | ctf_integer(pid_t, tid, p->pid) | |
5aa835c0 | 178 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) |
f127e61e | 179 | ctf_integer(int, success, success) |
7c68b363 | 180 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f127e61e | 181 | ctf_integer(int, target_cpu, task_cpu(p)) |
7c68b363 | 182 | #endif |
7c68b363 | 183 | ) |
f62b389e | 184 | ) |
ffcf2393 | 185 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ |
f62b389e | 186 | |
ffcf2393 MD |
187 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) |
188 | ||
189 | /* | |
190 | * Tracepoint called when waking a task; this tracepoint is guaranteed to be | |
191 | * called from the waking context. | |
192 | */ | |
193 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_waking, | |
194 | TP_PROTO(struct task_struct *p), | |
195 | TP_ARGS(p)) | |
196 | ||
197 | /* | |
198 | * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG. | |
199 | * It it not always called from the waking context. | |
200 | */ | |
201 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, | |
202 | TP_PROTO(struct task_struct *p), | |
203 | TP_ARGS(p)) | |
204 | ||
205 | /* | |
206 | * Tracepoint for waking up a new task: | |
207 | */ | |
208 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, | |
209 | TP_PROTO(struct task_struct *p), | |
210 | TP_ARGS(p)) | |
211 | ||
212 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
3a523f5b | 213 | |
3bc29f0a | 214 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
f62b389e MD |
215 | TP_PROTO(struct task_struct *p, int success), |
216 | TP_ARGS(p, success)) | |
217 | ||
218 | /* | |
219 | * Tracepoint for waking up a new task: | |
220 | */ | |
3bc29f0a | 221 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
f62b389e MD |
222 | TP_PROTO(struct task_struct *p, int success), |
223 | TP_ARGS(p, success)) | |
224 | ||
3a523f5b MD |
225 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
226 | ||
3bc29f0a | 227 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup, |
3a523f5b MD |
228 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
229 | TP_ARGS(rq, p, success)) | |
230 | ||
231 | /* | |
232 | * Tracepoint for waking up a new task: | |
233 | */ | |
3bc29f0a | 234 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new, |
3a523f5b MD |
235 | TP_PROTO(struct rq *rq, struct task_struct *p, int success), |
236 | TP_ARGS(rq, p, success)) | |
237 | ||
238 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
239 | ||
f62b389e MD |
240 | /* |
241 | * Tracepoint for task switches, performed by the scheduler: | |
242 | */ | |
3bc29f0a | 243 | LTTNG_TRACEPOINT_EVENT(sched_switch, |
f62b389e | 244 | |
3ee729fe MD |
245 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) |
246 | TP_PROTO(bool preempt, | |
247 | struct task_struct *prev, | |
248 | struct task_struct *next), | |
249 | ||
250 | TP_ARGS(preempt, prev, next), | |
251 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
f62b389e MD |
252 | TP_PROTO(struct task_struct *prev, |
253 | struct task_struct *next), | |
254 | ||
255 | TP_ARGS(prev, next), | |
3a523f5b MD |
256 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
257 | TP_PROTO(struct rq *rq, struct task_struct *prev, | |
258 | struct task_struct *next), | |
259 | ||
260 | TP_ARGS(rq, prev, next), | |
261 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e | 262 | |
f127e61e MD |
263 | TP_FIELDS( |
264 | ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN) | |
265 | ctf_integer(pid_t, prev_tid, prev->pid) | |
266 | ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO) | |
3ee729fe MD |
267 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)) |
268 | ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev)) | |
269 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) | |
f127e61e | 270 | ctf_integer(long, prev_state, __trace_sched_switch_state(prev)) |
7c68b363 | 271 | #else |
f127e61e | 272 | ctf_integer(long, prev_state, prev->state) |
7c68b363 | 273 | #endif |
f127e61e MD |
274 | ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN) |
275 | ctf_integer(pid_t, next_tid, next->pid) | |
276 | ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO) | |
277 | ) | |
f62b389e MD |
278 | ) |
279 | ||
280 | /* | |
281 | * Tracepoint for a task being migrated: | |
282 | */ | |
3bc29f0a | 283 | LTTNG_TRACEPOINT_EVENT(sched_migrate_task, |
f62b389e MD |
284 | |
285 | TP_PROTO(struct task_struct *p, int dest_cpu), | |
286 | ||
287 | TP_ARGS(p, dest_cpu), | |
288 | ||
f127e61e MD |
289 | TP_FIELDS( |
290 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
291 | ctf_integer(pid_t, tid, p->pid) | |
292 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) | |
293 | ctf_integer(int, orig_cpu, task_cpu(p)) | |
294 | ctf_integer(int, dest_cpu, dest_cpu) | |
295 | ) | |
f62b389e MD |
296 | ) |
297 | ||
3bc29f0a | 298 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_process_template, |
f62b389e MD |
299 | |
300 | TP_PROTO(struct task_struct *p), | |
301 | ||
302 | TP_ARGS(p), | |
303 | ||
f127e61e MD |
304 | TP_FIELDS( |
305 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
306 | ctf_integer(pid_t, tid, p->pid) | |
307 | ctf_integer(int, prio, p->prio - MAX_RT_PRIO) | |
308 | ) | |
f62b389e MD |
309 | ) |
310 | ||
311 | /* | |
312 | * Tracepoint for freeing a task: | |
313 | */ | |
3bc29f0a | 314 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_free, |
f62b389e MD |
315 | TP_PROTO(struct task_struct *p), |
316 | TP_ARGS(p)) | |
317 | ||
318 | ||
319 | /* | |
320 | * Tracepoint for a task exiting: | |
321 | */ | |
3bc29f0a | 322 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_process_exit, |
f62b389e MD |
323 | TP_PROTO(struct task_struct *p), |
324 | TP_ARGS(p)) | |
325 | ||
326 | /* | |
327 | * Tracepoint for waiting on task to unschedule: | |
328 | */ | |
3a523f5b | 329 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) |
3bc29f0a | 330 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
f62b389e MD |
331 | TP_PROTO(struct task_struct *p), |
332 | TP_ARGS(p)) | |
3a523f5b | 333 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ |
3bc29f0a | 334 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_process_template, sched_wait_task, |
3a523f5b MD |
335 | TP_PROTO(struct rq *rq, struct task_struct *p), |
336 | TP_ARGS(rq, p)) | |
337 | #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */ | |
f62b389e MD |
338 | |
339 | /* | |
340 | * Tracepoint for a waiting task: | |
341 | */ | |
3bc29f0a | 342 | LTTNG_TRACEPOINT_EVENT(sched_process_wait, |
f62b389e MD |
343 | |
344 | TP_PROTO(struct pid *pid), | |
345 | ||
346 | TP_ARGS(pid), | |
347 | ||
f127e61e MD |
348 | TP_FIELDS( |
349 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
350 | ctf_integer(pid_t, tid, pid_nr(pid)) | |
351 | ctf_integer(int, prio, current->prio - MAX_RT_PRIO) | |
352 | ) | |
f62b389e MD |
353 | ) |
354 | ||
355 | /* | |
79b18ef7 MD |
356 | * Tracepoint for do_fork. |
357 | * Saving both TID and PID information, especially for the child, allows | |
358 | * trace analyzers to distinguish between creation of a new process and | |
359 | * creation of a new thread. Newly created processes will have child_tid | |
360 | * == child_pid, while creation of a thread yields to child_tid != | |
361 | * child_pid. | |
f62b389e | 362 | */ |
7bbf55ea | 363 | LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork, |
f62b389e MD |
364 | |
365 | TP_PROTO(struct task_struct *parent, struct task_struct *child), | |
366 | ||
367 | TP_ARGS(parent, child), | |
368 | ||
7bbf55ea SL |
369 | TP_locvar( |
370 | pid_t vtids[LTTNG_MAX_PID_NS_LEVEL]; | |
371 | unsigned int ns_level; | |
372 | ), | |
373 | ||
265822ae | 374 | TP_code_pre( |
7bbf55ea SL |
375 | if (child) { |
376 | struct pid *child_pid; | |
377 | unsigned int i; | |
378 | ||
379 | child_pid = task_pid(child); | |
380 | tp_locvar->ns_level = | |
381 | min_t(unsigned int, child_pid->level + 1, | |
382 | LTTNG_MAX_PID_NS_LEVEL); | |
383 | for (i = 0; i < tp_locvar->ns_level; i++) | |
384 | tp_locvar->vtids[i] = child_pid->numbers[i].nr; | |
385 | } | |
386 | ), | |
387 | ||
f127e61e MD |
388 | TP_FIELDS( |
389 | ctf_array_text(char, parent_comm, parent->comm, TASK_COMM_LEN) | |
390 | ctf_integer(pid_t, parent_tid, parent->pid) | |
391 | ctf_integer(pid_t, parent_pid, parent->tgid) | |
7bbf55ea SL |
392 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
393 | ctf_integer(unsigned int, parent_ns_inum, | |
394 | ({ | |
395 | unsigned int parent_ns_inum = 0; | |
396 | ||
397 | if (parent) { | |
398 | struct pid_namespace *pid_ns; | |
399 | ||
400 | pid_ns = task_active_pid_ns(parent); | |
401 | if (pid_ns) | |
402 | parent_ns_inum = | |
403 | pid_ns->lttng_proc_inum; | |
404 | } | |
405 | parent_ns_inum; | |
406 | })) | |
407 | #endif | |
f127e61e MD |
408 | ctf_array_text(char, child_comm, child->comm, TASK_COMM_LEN) |
409 | ctf_integer(pid_t, child_tid, child->pid) | |
7bbf55ea | 410 | ctf_sequence(pid_t, vtids, tp_locvar->vtids, u8, tp_locvar->ns_level) |
f127e61e | 411 | ctf_integer(pid_t, child_pid, child->tgid) |
7bbf55ea SL |
412 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
413 | ctf_integer(unsigned int, child_ns_inum, | |
414 | ({ | |
415 | unsigned int child_ns_inum = 0; | |
416 | ||
417 | if (child) { | |
418 | struct pid_namespace *pid_ns; | |
419 | ||
420 | pid_ns = task_active_pid_ns(child); | |
421 | if (pid_ns) | |
422 | child_ns_inum = | |
423 | pid_ns->lttng_proc_inum; | |
424 | } | |
425 | child_ns_inum; | |
426 | })) | |
427 | #endif | |
265822ae MD |
428 | ), |
429 | ||
430 | TP_code_post() | |
f62b389e MD |
431 | ) |
432 | ||
7c68b363 AG |
433 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) |
434 | /* | |
435 | * Tracepoint for sending a signal: | |
436 | */ | |
3bc29f0a | 437 | LTTNG_TRACEPOINT_EVENT(sched_signal_send, |
7c68b363 AG |
438 | |
439 | TP_PROTO(int sig, struct task_struct *p), | |
440 | ||
441 | TP_ARGS(sig, p), | |
442 | ||
f127e61e MD |
443 | TP_FIELDS( |
444 | ctf_integer(int, sig, sig) | |
445 | ctf_array_text(char, comm, p->comm, TASK_COMM_LEN) | |
446 | ctf_integer(pid_t, tid, p->pid) | |
447 | ) | |
7c68b363 AG |
448 | ) |
449 | #endif | |
450 | ||
c94b2508 | 451 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
46142a81 PW |
452 | /* |
453 | * Tracepoint for exec: | |
454 | */ | |
3bc29f0a | 455 | LTTNG_TRACEPOINT_EVENT(sched_process_exec, |
46142a81 PW |
456 | |
457 | TP_PROTO(struct task_struct *p, pid_t old_pid, | |
458 | struct linux_binprm *bprm), | |
459 | ||
460 | TP_ARGS(p, old_pid, bprm), | |
461 | ||
f127e61e MD |
462 | TP_FIELDS( |
463 | ctf_string(filename, bprm->filename) | |
464 | ctf_integer(pid_t, tid, p->pid) | |
465 | ctf_integer(pid_t, old_tid, old_pid) | |
466 | ) | |
46142a81 | 467 | ) |
c94b2508 | 468 | #endif |
46142a81 | 469 | |
7c68b363 | 470 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e MD |
471 | /* |
472 | * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE | |
473 | * adding sched_stat support to SCHED_FIFO/RR would be welcome. | |
474 | */ | |
3bc29f0a | 475 | LTTNG_TRACEPOINT_EVENT_CLASS(sched_stat_template, |
f62b389e MD |
476 | |
477 | TP_PROTO(struct task_struct *tsk, u64 delay), | |
478 | ||
479 | TP_ARGS(tsk, delay), | |
480 | ||
f127e61e MD |
481 | TP_FIELDS( |
482 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
483 | ctf_integer(pid_t, tid, tsk->pid) | |
484 | ctf_integer(u64, delay, delay) | |
f62b389e | 485 | ) |
f62b389e MD |
486 | ) |
487 | ||
488 | ||
489 | /* | |
490 | * Tracepoint for accounting wait time (time the task is runnable | |
491 | * but not actually running due to scheduler contention). | |
492 | */ | |
3bc29f0a | 493 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_wait, |
f62b389e MD |
494 | TP_PROTO(struct task_struct *tsk, u64 delay), |
495 | TP_ARGS(tsk, delay)) | |
496 | ||
497 | /* | |
498 | * Tracepoint for accounting sleep time (time the task is not runnable, | |
499 | * including iowait, see below). | |
500 | */ | |
3bc29f0a | 501 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_sleep, |
f62b389e MD |
502 | TP_PROTO(struct task_struct *tsk, u64 delay), |
503 | TP_ARGS(tsk, delay)) | |
504 | ||
505 | /* | |
506 | * Tracepoint for accounting iowait time (time the task is not runnable | |
507 | * due to waiting on IO to complete). | |
508 | */ | |
3bc29f0a | 509 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_iowait, |
f62b389e MD |
510 | TP_PROTO(struct task_struct *tsk, u64 delay), |
511 | TP_ARGS(tsk, delay)) | |
512 | ||
7c68b363 AG |
513 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) |
514 | /* | |
515 | * Tracepoint for accounting blocked time (time the task is in uninterruptible). | |
516 | */ | |
3bc29f0a | 517 | LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_stat_template, sched_stat_blocked, |
7c68b363 AG |
518 | TP_PROTO(struct task_struct *tsk, u64 delay), |
519 | TP_ARGS(tsk, delay)) | |
520 | #endif | |
521 | ||
f62b389e MD |
522 | /* |
523 | * Tracepoint for accounting runtime (time the task is executing | |
524 | * on a CPU). | |
525 | */ | |
3bc29f0a | 526 | LTTNG_TRACEPOINT_EVENT(sched_stat_runtime, |
f62b389e MD |
527 | |
528 | TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime), | |
529 | ||
530 | TP_ARGS(tsk, runtime, vruntime), | |
531 | ||
f127e61e MD |
532 | TP_FIELDS( |
533 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
534 | ctf_integer(pid_t, tid, tsk->pid) | |
535 | ctf_integer(u64, runtime, runtime) | |
536 | ctf_integer(u64, vruntime, vruntime) | |
f62b389e | 537 | ) |
f62b389e | 538 | ) |
7c68b363 | 539 | #endif |
f62b389e | 540 | |
7c68b363 | 541 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) |
f62b389e MD |
542 | /* |
543 | * Tracepoint for showing priority inheritance modifying a tasks | |
544 | * priority. | |
545 | */ | |
3bc29f0a | 546 | LTTNG_TRACEPOINT_EVENT(sched_pi_setprio, |
f62b389e MD |
547 | |
548 | TP_PROTO(struct task_struct *tsk, int newprio), | |
549 | ||
550 | TP_ARGS(tsk, newprio), | |
551 | ||
f127e61e MD |
552 | TP_FIELDS( |
553 | ctf_array_text(char, comm, tsk->comm, TASK_COMM_LEN) | |
554 | ctf_integer(pid_t, tid, tsk->pid) | |
555 | ctf_integer(int, oldprio, tsk->prio - MAX_RT_PRIO) | |
556 | ctf_integer(int, newprio, newprio - MAX_RT_PRIO) | |
557 | ) | |
f62b389e | 558 | ) |
7c68b363 | 559 | #endif |
f62b389e | 560 | |
3bc29f0a | 561 | #endif /* LTTNG_TRACE_SCHED_H */ |
f62b389e MD |
562 | |
563 | /* This part must be outside protection */ | |
5b88d86e | 564 | #include "../../../probes/define_trace.h" |