2 #define TRACE_SYSTEM sched
4 #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/sched.h>
8 #include <linux/tracepoint.h>
9 #include <linux/binfmts.h>
11 #define SCHEDULING_POLICY \
12 EM( SCHED_NORMAL, "SCHED_NORMAL") \
13 EM( SCHED_FIFO, "SCHED_FIFO") \
14 EM( SCHED_RR, "SCHED_RR") \
15 EM( SCHED_BATCH, "SCHED_BATCH") \
16 EM( SCHED_IDLE, "SCHED_IDLE") \
17 EMe(SCHED_DEADLINE, "SCHED_DEADLINE")
20 * First define the enums in the above macros to be exported to userspace
21 * via TRACE_DEFINE_ENUM().
25 #define EM(a, b) TRACE_DEFINE_ENUM(a);
26 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
31 * Now redefine the EM() and EMe() macros to map the enums to the strings
32 * that will be printed in the output.
36 #define EM(a, b) {a, b},
37 #define EMe(a, b) {a, b}
40 * Tracepoint for calling kthread_stop, performed to end a kthread:
42 TRACE_EVENT(sched_kthread_stop
,
44 TP_PROTO(struct task_struct
*t
),
49 __array( char, comm
, TASK_COMM_LEN
)
54 memcpy(__entry
->comm
, t
->comm
, TASK_COMM_LEN
);
55 __entry
->pid
= t
->pid
;
58 TP_printk("comm=%s pid=%d", __entry
->comm
, __entry
->pid
)
62 * Tracepoint for the return value of the kthread stopping:
64 TRACE_EVENT(sched_kthread_stop_ret
,
78 TP_printk("ret=%d", __entry
->ret
)
82 * Tracepoint for waking up a task:
84 DECLARE_EVENT_CLASS(sched_wakeup_template
,
86 TP_PROTO(struct task_struct
*p
),
88 TP_ARGS(__perf_task(p
)),
91 __array( char, comm
, TASK_COMM_LEN
)
94 __field( int, success
)
95 __field( int, target_cpu
)
99 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
100 __entry
->pid
= p
->pid
;
101 __entry
->prio
= p
->prio
;
102 __entry
->success
= 1; /* rudiment, kill when possible */
103 __entry
->target_cpu
= task_cpu(p
);
106 TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
107 __entry
->comm
, __entry
->pid
, __entry
->prio
,
112 * Tracepoint called when waking a task; this tracepoint is guaranteed to be
113 * called from the waking context.
115 DEFINE_EVENT(sched_wakeup_template
, sched_waking
,
116 TP_PROTO(struct task_struct
*p
),
120 * Tracepoint called when the task is actually woken; p->state == TASK_RUNNNG.
121 * It it not always called from the waking context.
123 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup
,
124 TP_PROTO(struct task_struct
*p
),
128 * Tracepoint for waking up a new task:
130 DEFINE_EVENT(sched_wakeup_template
, sched_wakeup_new
,
131 TP_PROTO(struct task_struct
*p
),
134 TRACE_EVENT_MAP(sched_waking
, sched_waking_prio
,
136 TP_PROTO(struct task_struct
*p
),
141 __array( char, comm
, TASK_COMM_LEN
)
142 __field( pid_t
, pid
)
143 __field( int, target_cpu
)
144 __field( unsigned int, policy
)
146 __field( unsigned int, rt_priority
)
147 __field( u64
, dl_runtime
)
148 __field( u64
, dl_deadline
)
149 __field( u64
, dl_period
)
150 __array( char, top_waiter_comm
, TASK_COMM_LEN
)
151 __field( pid_t
, top_waiter_pid
)
155 struct task_struct
*top_waiter
= rt_mutex_get_top_task(p
);
157 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
158 __entry
->pid
= p
->pid
;
159 __entry
->target_cpu
= task_cpu(p
);
160 __entry
->policy
= rt_mutex_get_effective_policy(
162 __entry
->nice
= task_nice(p
);
163 __entry
->rt_priority
= rt_mutex_get_effective_rt_prio(
165 __entry
->dl_runtime
= dl_prio(p
->prio
) ?
166 p
->dl
.dl_runtime
: 0;
167 __entry
->dl_deadline
= dl_prio(p
->prio
) ?
168 p
->dl
.dl_deadline
: 0;
169 __entry
->dl_period
= dl_prio(p
->prio
) ?
172 memcpy(__entry
->top_waiter_comm
, top_waiter
->comm
,
174 __entry
->top_waiter_pid
= top_waiter
->pid
;
176 __entry
->top_waiter_comm
[0] = '\0';
177 __entry
->top_waiter_pid
= -1;
181 TP_printk("comm=%s, pid=%d, target_cpu=%03d, policy=%s, "
182 "nice=%d, rt_priority=%u, dl_runtime=%Lu, "
183 "dl_deadline=%Lu, dl_period=%Lu, "
184 "top_waiter_comm=%s, top_waiter_pid=%d",
185 __entry
->comm
, __entry
->pid
, __entry
->target_cpu
,
186 __print_symbolic(__entry
->policy
, SCHEDULING_POLICY
),
187 __entry
->nice
, __entry
->rt_priority
, __entry
->dl_runtime
,
188 __entry
->dl_deadline
, __entry
->dl_period
,
189 __entry
->top_waiter_comm
, __entry
->top_waiter_pid
)
192 #ifdef CREATE_TRACE_POINTS
193 static inline long __trace_sched_switch_state(bool preempt
, struct task_struct
*p
)
195 #ifdef CONFIG_SCHED_DEBUG
196 BUG_ON(p
!= current
);
197 #endif /* CONFIG_SCHED_DEBUG */
200 * Preemption ignores task state, therefore preempted tasks are always
201 * RUNNING (we will not have dequeued if state != RUNNING).
203 return preempt
? TASK_RUNNING
| TASK_STATE_MAX
: p
->state
;
205 #endif /* CREATE_TRACE_POINTS */
208 * Tracepoint for task switches, performed by the scheduler:
210 TRACE_EVENT(sched_switch
,
212 TP_PROTO(bool preempt
,
213 struct task_struct
*prev
,
214 struct task_struct
*next
),
216 TP_ARGS(preempt
, prev
, next
),
219 __array( char, prev_comm
, TASK_COMM_LEN
)
220 __field( pid_t
, prev_pid
)
221 __field( int, prev_prio
)
222 __field( long, prev_state
)
223 __array( char, next_comm
, TASK_COMM_LEN
)
224 __field( pid_t
, next_pid
)
225 __field( int, next_prio
)
229 memcpy(__entry
->next_comm
, next
->comm
, TASK_COMM_LEN
);
230 __entry
->prev_pid
= prev
->pid
;
231 __entry
->prev_prio
= prev
->prio
;
232 __entry
->prev_state
= __trace_sched_switch_state(preempt
, prev
);
233 memcpy(__entry
->prev_comm
, prev
->comm
, TASK_COMM_LEN
);
234 __entry
->next_pid
= next
->pid
;
235 __entry
->next_prio
= next
->prio
;
238 TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
239 __entry
->prev_comm
, __entry
->prev_pid
, __entry
->prev_prio
,
240 __entry
->prev_state
& (TASK_STATE_MAX
-1) ?
241 __print_flags(__entry
->prev_state
& (TASK_STATE_MAX
-1), "|",
242 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
243 { 16, "Z" }, { 32, "X" }, { 64, "x" },
244 { 128, "K" }, { 256, "W" }, { 512, "P" },
245 { 1024, "N" }) : "R",
246 __entry
->prev_state
& TASK_STATE_MAX
? "+" : "",
247 __entry
->next_comm
, __entry
->next_pid
, __entry
->next_prio
)
251 * Tracepoint for task switches, performed by the scheduler:
253 TRACE_EVENT_MAP(sched_switch
, sched_switch_prio
,
254 TP_PROTO(bool preempt
,
255 struct task_struct
*prev
,
256 struct task_struct
*next
),
258 TP_ARGS(preempt
, prev
, next
),
261 __array( char, prev_comm
, TASK_COMM_LEN
)
262 __field( pid_t
, prev_pid
)
263 __field( long, prev_state
)
264 __field( unsigned int, prev_policy
)
265 __field( int, prev_nice
)
266 __field( unsigned int, prev_rt_priority
)
267 __field( u64
, prev_dl_runtime
)
268 __field( u64
, prev_dl_deadline
)
269 __field( u64
, prev_dl_period
)
270 __array( char, prev_top_waiter_comm
, TASK_COMM_LEN
)
271 __field( pid_t
, prev_top_waiter_pid
)
272 __array( char, next_comm
, TASK_COMM_LEN
)
273 __field( pid_t
, next_pid
)
274 __field( unsigned int, next_policy
)
275 __field( int, next_nice
)
276 __field( unsigned int, next_rt_priority
)
277 __field( u64
, next_dl_runtime
)
278 __field( u64
, next_dl_deadline
)
279 __field( u64
, next_dl_period
)
280 __array( char, next_top_waiter_comm
, TASK_COMM_LEN
)
281 __field( pid_t
, next_top_waiter_pid
)
285 struct task_struct
*prev_top
= rt_mutex_get_top_task(prev
);
286 struct task_struct
*next_top
= rt_mutex_get_top_task(next
);
288 memcpy(__entry
->prev_comm
, prev
->comm
, TASK_COMM_LEN
);
289 __entry
->prev_pid
= prev
->pid
;
290 __entry
->prev_state
= __trace_sched_switch_state(
292 __entry
->prev_policy
= rt_mutex_get_effective_policy(
293 prev
->policy
, prev
->prio
);
294 __entry
->prev_nice
= task_nice(prev
);
295 __entry
->prev_rt_priority
= rt_mutex_get_effective_rt_prio(
297 __entry
->prev_dl_runtime
= dl_prio(prev
->prio
) ?
298 prev
->dl
.dl_runtime
: 0;
299 __entry
->prev_dl_deadline
= dl_prio(prev
->prio
) ?
300 prev
->dl
.dl_deadline
: 0;
301 __entry
->prev_dl_period
= dl_prio(prev
->prio
) ?
302 prev
->dl
.dl_period
: 0;
304 memcpy(__entry
->prev_top_waiter_comm
, prev_top
->comm
,
306 __entry
->prev_top_waiter_pid
= prev_top
->pid
;
308 __entry
->prev_top_waiter_comm
[0] = '\0';
309 __entry
->prev_top_waiter_pid
= -1;
312 memcpy(__entry
->next_comm
, next
->comm
, TASK_COMM_LEN
);
313 __entry
->next_pid
= next
->pid
;
314 __entry
->next_policy
= rt_mutex_get_effective_policy(
315 next
->policy
, prev
->prio
);
316 __entry
->next_nice
= task_nice(next
);
317 __entry
->next_rt_priority
= rt_mutex_get_effective_rt_prio(
319 __entry
->next_dl_runtime
= dl_prio(next
->prio
) ?
320 next
->dl
.dl_runtime
: 0;
321 __entry
->next_dl_deadline
= dl_prio(next
->prio
) ?
322 next
->dl
.dl_deadline
: 0;
323 __entry
->next_dl_period
= dl_prio(next
->prio
) ?
324 next
->dl
.dl_period
: 0;
326 memcpy(__entry
->next_top_waiter_comm
, next_top
->comm
,
328 __entry
->next_top_waiter_pid
= next_top
->pid
;
330 __entry
->next_top_waiter_comm
[0] = '\0';
331 __entry
->next_top_waiter_pid
= -1;
335 TP_printk("prev_comm=%s, prev_pid=%d, prev_policy=%s, prev_nice=%d, "
336 "prev_rt_priority=%u, prev_dl_runtime=%Lu, "
337 "prev_dl_deadline=%Lu, prev_dl_period=%Lu, "
338 "prev_state=%s%s, prev_top_waiter_comm=%s, "
339 "prev_top_waiter_pid=%d ==> next_comm=%s, next_pid=%d, "
340 "next_policy=%s, next_nice=%d, next_rt_priority=%u, "
341 "next_dl_runtime=%Lu, next_dl_deadline=%Lu, "
342 "next_dl_period=%Lu, next_top_waiter_comm=%s, "
343 "next_top_waiter_pid=%d",
344 __entry
->prev_comm
, __entry
->prev_pid
,
345 __print_symbolic(__entry
->prev_policy
, SCHEDULING_POLICY
),
346 __entry
->prev_nice
, __entry
->prev_rt_priority
,
347 __entry
->prev_dl_runtime
, __entry
->prev_dl_deadline
,
348 __entry
->prev_dl_period
,
349 __entry
->prev_state
& (TASK_STATE_MAX
-1) ?
350 __print_flags(__entry
->prev_state
& (TASK_STATE_MAX
-1), "|",
351 { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
352 { 16, "Z" }, { 32, "X" }, { 64, "x" },
353 { 128, "K" }, { 256, "W" }, { 512, "P" },
354 { 1024, "N" }) : "R",
355 __entry
->prev_state
& TASK_STATE_MAX
? "+" : "",
356 __entry
->prev_top_waiter_comm
, __entry
->prev_top_waiter_pid
,
357 __entry
->next_comm
, __entry
->next_pid
,
358 __print_symbolic(__entry
->next_policy
, SCHEDULING_POLICY
),
359 __entry
->next_nice
, __entry
->next_rt_priority
,
360 __entry
->next_dl_runtime
, __entry
->next_dl_deadline
,
361 __entry
->next_dl_period
, __entry
->next_top_waiter_comm
,
362 __entry
->next_top_waiter_pid
)
366 * Tracepoint for a task being migrated:
368 TRACE_EVENT(sched_migrate_task
,
370 TP_PROTO(struct task_struct
*p
, int dest_cpu
),
372 TP_ARGS(p
, dest_cpu
),
375 __array( char, comm
, TASK_COMM_LEN
)
376 __field( pid_t
, pid
)
378 __field( int, orig_cpu
)
379 __field( int, dest_cpu
)
383 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
384 __entry
->pid
= p
->pid
;
385 __entry
->prio
= p
->prio
;
386 __entry
->orig_cpu
= task_cpu(p
);
387 __entry
->dest_cpu
= dest_cpu
;
390 TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d",
391 __entry
->comm
, __entry
->pid
, __entry
->prio
,
392 __entry
->orig_cpu
, __entry
->dest_cpu
)
395 DECLARE_EVENT_CLASS(sched_process_template
,
397 TP_PROTO(struct task_struct
*p
),
402 __array( char, comm
, TASK_COMM_LEN
)
403 __field( pid_t
, pid
)
408 memcpy(__entry
->comm
, p
->comm
, TASK_COMM_LEN
);
409 __entry
->pid
= p
->pid
;
410 __entry
->prio
= p
->prio
;
413 TP_printk("comm=%s pid=%d prio=%d",
414 __entry
->comm
, __entry
->pid
, __entry
->prio
)
418 * Tracepoint for freeing a task:
420 DEFINE_EVENT(sched_process_template
, sched_process_free
,
421 TP_PROTO(struct task_struct
*p
),
426 * Tracepoint for a task exiting:
428 DEFINE_EVENT(sched_process_template
, sched_process_exit
,
429 TP_PROTO(struct task_struct
*p
),
433 * Tracepoint for waiting on task to unschedule:
435 DEFINE_EVENT(sched_process_template
, sched_wait_task
,
436 TP_PROTO(struct task_struct
*p
),
440 * Tracepoint for a waiting task:
442 TRACE_EVENT(sched_process_wait
,
444 TP_PROTO(struct pid
*pid
),
449 __array( char, comm
, TASK_COMM_LEN
)
450 __field( pid_t
, pid
)
455 memcpy(__entry
->comm
, current
->comm
, TASK_COMM_LEN
);
456 __entry
->pid
= pid_nr(pid
);
457 __entry
->prio
= current
->prio
;
460 TP_printk("comm=%s pid=%d prio=%d",
461 __entry
->comm
, __entry
->pid
, __entry
->prio
)
465 * Tracepoint for do_fork:
467 TRACE_EVENT(sched_process_fork
,
469 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
471 TP_ARGS(parent
, child
),
474 __array( char, parent_comm
, TASK_COMM_LEN
)
475 __field( pid_t
, parent_pid
)
476 __array( char, child_comm
, TASK_COMM_LEN
)
477 __field( pid_t
, child_pid
)
481 memcpy(__entry
->parent_comm
, parent
->comm
, TASK_COMM_LEN
);
482 __entry
->parent_pid
= parent
->pid
;
483 memcpy(__entry
->child_comm
, child
->comm
, TASK_COMM_LEN
);
484 __entry
->child_pid
= child
->pid
;
487 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
488 __entry
->parent_comm
, __entry
->parent_pid
,
489 __entry
->child_comm
, __entry
->child_pid
)
492 TRACE_EVENT_MAP(sched_process_fork
, sched_process_fork_prio
,
494 TP_PROTO(struct task_struct
*parent
, struct task_struct
*child
),
496 TP_ARGS(parent
, child
),
499 __array( char, parent_comm
, TASK_COMM_LEN
)
500 __field( pid_t
, parent_pid
)
501 __array( char, child_comm
, TASK_COMM_LEN
)
502 __field( pid_t
, child_pid
)
503 __field( unsigned int, child_policy
)
504 __field( int, child_nice
)
505 __field( unsigned int, child_rt_priority
)
506 __field( u64
, child_dl_runtime
)
507 __field( u64
, child_dl_deadline
)
508 __field( u64
, child_dl_period
)
512 memcpy(__entry
->parent_comm
, parent
->comm
, TASK_COMM_LEN
);
513 __entry
->parent_pid
= parent
->pid
;
514 memcpy(__entry
->child_comm
, child
->comm
, TASK_COMM_LEN
);
515 __entry
->child_pid
= child
->pid
;
516 __entry
->child_policy
= rt_mutex_get_effective_policy(
517 child
->policy
, child
->prio
);
518 __entry
->child_nice
= task_nice(child
);
519 __entry
->child_rt_priority
= rt_mutex_get_effective_rt_prio(
521 __entry
->child_dl_runtime
= dl_prio(child
->prio
) ?
522 child
->dl
.dl_runtime
: 0;
523 __entry
->child_dl_deadline
= dl_prio(child
->prio
) ?
524 child
->dl
.dl_deadline
: 0;
525 __entry
->child_dl_period
= dl_prio(child
->prio
) ?
526 child
->dl
.dl_period
: 0;
529 TP_printk("comm=%s, pid=%d, child_comm=%s, child_pid=%d, "
530 "child_policy=%s, child_nice=%d, "
531 "child_rt_priority=%u, child_dl_runtime=%Lu, "
532 "child_dl_deadline=%Lu, child_dl_period=%Lu",
533 __entry
->parent_comm
, __entry
->parent_pid
,
534 __entry
->child_comm
, __entry
->child_pid
,
535 __print_symbolic(__entry
->child_policy
, SCHEDULING_POLICY
),
536 __entry
->child_nice
, __entry
->child_rt_priority
,
537 __entry
->child_dl_runtime
, __entry
->child_dl_deadline
,
538 __entry
->child_dl_period
)
542 * Tracepoint for exec:
544 TRACE_EVENT(sched_process_exec
,
546 TP_PROTO(struct task_struct
*p
, pid_t old_pid
,
547 struct linux_binprm
*bprm
),
549 TP_ARGS(p
, old_pid
, bprm
),
552 __string( filename
, bprm
->filename
)
553 __field( pid_t
, pid
)
554 __field( pid_t
, old_pid
)
558 __assign_str(filename
, bprm
->filename
);
559 __entry
->pid
= p
->pid
;
560 __entry
->old_pid
= old_pid
;
563 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename
),
564 __entry
->pid
, __entry
->old_pid
)
568 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
569 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
571 DECLARE_EVENT_CLASS(sched_stat_template
,
573 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
575 TP_ARGS(__perf_task(tsk
), __perf_count(delay
)),
578 __array( char, comm
, TASK_COMM_LEN
)
579 __field( pid_t
, pid
)
580 __field( u64
, delay
)
584 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
585 __entry
->pid
= tsk
->pid
;
586 __entry
->delay
= delay
;
589 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
590 __entry
->comm
, __entry
->pid
,
591 (unsigned long long)__entry
->delay
)
596 * Tracepoint for accounting wait time (time the task is runnable
597 * but not actually running due to scheduler contention).
599 DEFINE_EVENT(sched_stat_template
, sched_stat_wait
,
600 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
601 TP_ARGS(tsk
, delay
));
604 * Tracepoint for accounting sleep time (time the task is not runnable,
605 * including iowait, see below).
607 DEFINE_EVENT(sched_stat_template
, sched_stat_sleep
,
608 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
609 TP_ARGS(tsk
, delay
));
612 * Tracepoint for accounting iowait time (time the task is not runnable
613 * due to waiting on IO to complete).
615 DEFINE_EVENT(sched_stat_template
, sched_stat_iowait
,
616 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
617 TP_ARGS(tsk
, delay
));
620 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
622 DEFINE_EVENT(sched_stat_template
, sched_stat_blocked
,
623 TP_PROTO(struct task_struct
*tsk
, u64 delay
),
624 TP_ARGS(tsk
, delay
));
627 * Tracepoint for accounting runtime (time the task is executing
630 DECLARE_EVENT_CLASS(sched_stat_runtime
,
632 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
634 TP_ARGS(tsk
, __perf_count(runtime
), vruntime
),
637 __array( char, comm
, TASK_COMM_LEN
)
638 __field( pid_t
, pid
)
639 __field( u64
, runtime
)
640 __field( u64
, vruntime
)
644 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
645 __entry
->pid
= tsk
->pid
;
646 __entry
->runtime
= runtime
;
647 __entry
->vruntime
= vruntime
;
650 TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
651 __entry
->comm
, __entry
->pid
,
652 (unsigned long long)__entry
->runtime
,
653 (unsigned long long)__entry
->vruntime
)
656 DEFINE_EVENT(sched_stat_runtime
, sched_stat_runtime
,
657 TP_PROTO(struct task_struct
*tsk
, u64 runtime
, u64 vruntime
),
658 TP_ARGS(tsk
, runtime
, vruntime
));
661 * Tracepoint for showing priority inheritance modifying a tasks
664 TRACE_EVENT(sched_pi_setprio
,
666 TP_PROTO(struct task_struct
*tsk
, int newprio
),
668 TP_ARGS(tsk
, newprio
),
671 __array( char, comm
, TASK_COMM_LEN
)
672 __field( pid_t
, pid
)
673 __field( int, oldprio
)
674 __field( int, newprio
)
678 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
679 __entry
->pid
= tsk
->pid
;
680 __entry
->oldprio
= tsk
->prio
;
681 __entry
->newprio
= newprio
;
684 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
685 __entry
->comm
, __entry
->pid
,
686 __entry
->oldprio
, __entry
->newprio
)
690 * Extract the complete scheduling information from the before
691 * and after the change of priority.
693 TRACE_EVENT_MAP(sched_pi_setprio
, sched_pi_update_prio
,
695 TP_PROTO(struct task_struct
*tsk
, int newprio
),
697 TP_ARGS(tsk
, newprio
),
700 __array( char, comm
, TASK_COMM_LEN
)
701 __field( pid_t
, pid
)
702 __field( unsigned int, old_policy
)
703 __field( int, old_nice
)
704 __field( unsigned int, old_rt_priority
)
705 __field( u64
, old_dl_runtime
)
706 __field( u64
, old_dl_deadline
)
707 __field( u64
, old_dl_period
)
708 __array( char, top_waiter_comm
, TASK_COMM_LEN
)
709 __field( pid_t
, top_waiter_pid
)
710 __field( unsigned int, new_policy
)
711 __field( int, new_nice
)
712 __field( unsigned int, new_rt_priority
)
713 __field( u64
, new_dl_runtime
)
714 __field( u64
, new_dl_deadline
)
715 __field( u64
, new_dl_period
)
719 struct task_struct
*top_waiter
= rt_mutex_get_top_task(tsk
);
721 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
722 __entry
->pid
= tsk
->pid
;
723 __entry
->old_policy
= rt_mutex_get_effective_policy(
724 tsk
->policy
, tsk
->prio
);
725 __entry
->old_nice
= task_nice(tsk
);
726 __entry
->old_rt_priority
= rt_mutex_get_effective_rt_prio(
728 __entry
->old_dl_runtime
= dl_prio(tsk
->prio
) ?
729 tsk
->dl
.dl_runtime
: 0;
730 __entry
->old_dl_deadline
= dl_prio(tsk
->prio
) ?
731 tsk
->dl
.dl_deadline
: 0;
732 __entry
->old_dl_period
= dl_prio(tsk
->prio
) ?
733 tsk
->dl
.dl_period
: 0;
735 memcpy(__entry
->top_waiter_comm
, top_waiter
->comm
, TASK_COMM_LEN
);
736 __entry
->top_waiter_pid
= top_waiter
->pid
;
738 * The effective policy depends on the current policy of
741 __entry
->new_policy
= rt_mutex_get_effective_policy(
742 tsk
->policy
, top_waiter
->prio
);
743 __entry
->new_nice
= task_nice(top_waiter
);
744 __entry
->new_rt_priority
= rt_mutex_get_effective_rt_prio(
746 __entry
->new_dl_runtime
= dl_prio(top_waiter
->prio
) ?
747 top_waiter
->dl
.dl_runtime
: 0;
748 __entry
->new_dl_deadline
= dl_prio(top_waiter
->prio
) ?
749 top_waiter
->dl
.dl_deadline
: 0;
750 __entry
->new_dl_period
= dl_prio(top_waiter
->prio
) ?
751 top_waiter
->dl
.dl_period
: 0;
753 __entry
->top_waiter_comm
[0] = '\0';
754 __entry
->top_waiter_pid
= -1;
755 __entry
->new_policy
= 0;
756 __entry
->new_nice
= 0;
757 __entry
->new_rt_priority
= 0;
758 __entry
->new_dl_runtime
= 0;
759 __entry
->new_dl_deadline
= 0;
760 __entry
->new_dl_period
= 0;
764 TP_printk("comm=%s, pid=%d, old_policy=%s, old_nice=%d, "
765 "old_rt_priority=%u, old_dl_runtime=%Lu, "
766 "old_dl_deadline=%Lu, old_dl_period=%Lu, "
767 "top_waiter_comm=%s, top_waiter_pid=%d, new_policy=%s, "
768 "new_nice=%d, new_rt_priority=%u, "
769 "new_dl_runtime=%Lu, new_dl_deadline=%Lu, "
771 __entry
->comm
, __entry
->pid
,
772 __print_symbolic(__entry
->old_policy
, SCHEDULING_POLICY
),
773 __entry
->old_nice
, __entry
->old_rt_priority
,
774 __entry
->old_dl_runtime
, __entry
->old_dl_deadline
,
775 __entry
->old_dl_period
,
776 __entry
->top_waiter_comm
, __entry
->top_waiter_pid
,
777 __entry
->new_policy
>= 0 ?
778 __print_symbolic(__entry
->new_policy
,
779 SCHEDULING_POLICY
) : "",
780 __entry
->new_nice
, __entry
->new_rt_priority
,
781 __entry
->new_dl_runtime
, __entry
->new_dl_deadline
,
782 __entry
->new_dl_period
)
785 #ifdef CONFIG_DETECT_HUNG_TASK
786 TRACE_EVENT(sched_process_hang
,
787 TP_PROTO(struct task_struct
*tsk
),
791 __array( char, comm
, TASK_COMM_LEN
)
792 __field( pid_t
, pid
)
796 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
797 __entry
->pid
= tsk
->pid
;
800 TP_printk("comm=%s pid=%d", __entry
->comm
, __entry
->pid
)
802 #endif /* CONFIG_DETECT_HUNG_TASK */
804 DECLARE_EVENT_CLASS(sched_move_task_template
,
806 TP_PROTO(struct task_struct
*tsk
, int src_cpu
, int dst_cpu
),
808 TP_ARGS(tsk
, src_cpu
, dst_cpu
),
811 __field( pid_t
, pid
)
812 __field( pid_t
, tgid
)
813 __field( pid_t
, ngid
)
814 __field( int, src_cpu
)
815 __field( int, src_nid
)
816 __field( int, dst_cpu
)
817 __field( int, dst_nid
)
821 __entry
->pid
= task_pid_nr(tsk
);
822 __entry
->tgid
= task_tgid_nr(tsk
);
823 __entry
->ngid
= task_numa_group_id(tsk
);
824 __entry
->src_cpu
= src_cpu
;
825 __entry
->src_nid
= cpu_to_node(src_cpu
);
826 __entry
->dst_cpu
= dst_cpu
;
827 __entry
->dst_nid
= cpu_to_node(dst_cpu
);
830 TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d",
831 __entry
->pid
, __entry
->tgid
, __entry
->ngid
,
832 __entry
->src_cpu
, __entry
->src_nid
,
833 __entry
->dst_cpu
, __entry
->dst_nid
)
837 * Tracks migration of tasks from one runqueue to another. Can be used to
838 * detect if automatic NUMA balancing is bouncing between nodes
840 DEFINE_EVENT(sched_move_task_template
, sched_move_numa
,
841 TP_PROTO(struct task_struct
*tsk
, int src_cpu
, int dst_cpu
),
843 TP_ARGS(tsk
, src_cpu
, dst_cpu
)
846 DEFINE_EVENT(sched_move_task_template
, sched_stick_numa
,
847 TP_PROTO(struct task_struct
*tsk
, int src_cpu
, int dst_cpu
),
849 TP_ARGS(tsk
, src_cpu
, dst_cpu
)
852 TRACE_EVENT(sched_swap_numa
,
854 TP_PROTO(struct task_struct
*src_tsk
, int src_cpu
,
855 struct task_struct
*dst_tsk
, int dst_cpu
),
857 TP_ARGS(src_tsk
, src_cpu
, dst_tsk
, dst_cpu
),
860 __field( pid_t
, src_pid
)
861 __field( pid_t
, src_tgid
)
862 __field( pid_t
, src_ngid
)
863 __field( int, src_cpu
)
864 __field( int, src_nid
)
865 __field( pid_t
, dst_pid
)
866 __field( pid_t
, dst_tgid
)
867 __field( pid_t
, dst_ngid
)
868 __field( int, dst_cpu
)
869 __field( int, dst_nid
)
873 __entry
->src_pid
= task_pid_nr(src_tsk
);
874 __entry
->src_tgid
= task_tgid_nr(src_tsk
);
875 __entry
->src_ngid
= task_numa_group_id(src_tsk
);
876 __entry
->src_cpu
= src_cpu
;
877 __entry
->src_nid
= cpu_to_node(src_cpu
);
878 __entry
->dst_pid
= task_pid_nr(dst_tsk
);
879 __entry
->dst_tgid
= task_tgid_nr(dst_tsk
);
880 __entry
->dst_ngid
= task_numa_group_id(dst_tsk
);
881 __entry
->dst_cpu
= dst_cpu
;
882 __entry
->dst_nid
= cpu_to_node(dst_cpu
);
885 TP_printk("src_pid=%d src_tgid=%d src_ngid=%d src_cpu=%d src_nid=%d dst_pid=%d dst_tgid=%d dst_ngid=%d dst_cpu=%d dst_nid=%d",
886 __entry
->src_pid
, __entry
->src_tgid
, __entry
->src_ngid
,
887 __entry
->src_cpu
, __entry
->src_nid
,
888 __entry
->dst_pid
, __entry
->dst_tgid
, __entry
->dst_ngid
,
889 __entry
->dst_cpu
, __entry
->dst_nid
)
893 * Tracepoint for waking a polling cpu without an IPI.
895 TRACE_EVENT(sched_wake_idle_without_ipi
,
909 TP_printk("cpu=%d", __entry
->cpu
)
913 * Tracepoint for showing scheduling priority changes.
915 TRACE_EVENT(sched_update_prio
,
917 TP_PROTO(struct task_struct
*tsk
),
922 __array( char, comm
, TASK_COMM_LEN
)
923 __field( pid_t
, pid
)
924 __field( unsigned int, policy
)
926 __field( unsigned int, rt_priority
)
927 __field( u64
, dl_runtime
)
928 __field( u64
, dl_deadline
)
929 __field( u64
, dl_period
)
933 memcpy(__entry
->comm
, tsk
->comm
, TASK_COMM_LEN
);
934 __entry
->pid
= tsk
->pid
;
935 __entry
->policy
= tsk
->policy
;
936 __entry
->nice
= task_nice(tsk
);
937 __entry
->rt_priority
= tsk
->rt_priority
;
938 __entry
->dl_runtime
= tsk
->dl
.dl_runtime
;
939 __entry
->dl_deadline
= tsk
->dl
.dl_deadline
;
940 __entry
->dl_period
= tsk
->dl
.dl_period
;
943 TP_printk("comm=%s pid=%d, policy=%s, nice=%d, rt_priority=%u, "
944 "dl_runtime=%Lu, dl_deadline=%Lu, dl_period=%Lu",
945 __entry
->comm
, __entry
->pid
,
946 __print_symbolic(__entry
->policy
, SCHEDULING_POLICY
),
947 __entry
->nice
, __entry
->rt_priority
,
948 __entry
->dl_runtime
, __entry
->dl_deadline
,
951 #endif /* _TRACE_SCHED_H */
953 /* This part must be outside protection */
954 #include <trace/define_trace.h>