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