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