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