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