1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM sched
4
5 #if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_SCHED_H
7
8 #include <linux/kthread.h>
9 #include <linux/sched/numa_balancing.h>
10 #include <linux/sched/clock.h>
11 #include <linux/tracepoint.h>
12 #include <linux/binfmts.h>
13
14 #ifdef CONFIG_SCHED_RT_CAS
15 #include "eas_sched.h"
16 #endif
17
18 /*
19 * Tracepoint for calling kthread_stop, performed to end a kthread:
20 */
21 TRACE_EVENT(sched_kthread_stop,
22
23 TP_PROTO(struct task_struct *t),
24
25 TP_ARGS(t),
26
27 TP_STRUCT__entry(
28 __array( char, comm, TASK_COMM_LEN )
29 __field( pid_t, pid )
30 ),
31
32 TP_fast_assign(
33 memcpy(__entry->comm, t->comm, TASK_COMM_LEN);
34 __entry->pid = t->pid;
35 ),
36
37 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
38 );
39
40 /*
41 * Tracepoint for the return value of the kthread stopping:
42 */
43 TRACE_EVENT(sched_kthread_stop_ret,
44
45 TP_PROTO(int ret),
46
47 TP_ARGS(ret),
48
49 TP_STRUCT__entry(
50 __field( int, ret )
51 ),
52
53 TP_fast_assign(
54 __entry->ret = ret;
55 ),
56
57 TP_printk("ret=%d", __entry->ret)
58 );
59
60 /**
61 * sched_kthread_work_queue_work - called when a work gets queued
62 * @worker: pointer to the kthread_worker
63 * @work: pointer to struct kthread_work
64 *
65 * This event occurs when a work is queued immediately or once a
66 * delayed work is actually queued (ie: once the delay has been
67 * reached).
68 */
69 TRACE_EVENT(sched_kthread_work_queue_work,
70
71 TP_PROTO(struct kthread_worker *worker,
72 struct kthread_work *work),
73
74 TP_ARGS(worker, work),
75
76 TP_STRUCT__entry(
77 __field( void *, work )
78 __field( void *, function)
79 __field( void *, worker)
80 ),
81
82 TP_fast_assign(
83 __entry->work = work;
84 __entry->function = work->func;
85 __entry->worker = worker;
86 ),
87
88 TP_printk("work struct=%p function=%ps worker=%p",
89 __entry->work, __entry->function, __entry->worker)
90 );
91
92 /**
93 * sched_kthread_work_execute_start - called immediately before the work callback
94 * @work: pointer to struct kthread_work
95 *
96 * Allows to track kthread work execution.
97 */
98 TRACE_EVENT(sched_kthread_work_execute_start,
99
100 TP_PROTO(struct kthread_work *work),
101
102 TP_ARGS(work),
103
104 TP_STRUCT__entry(
105 __field( void *, work )
106 __field( void *, function)
107 ),
108
109 TP_fast_assign(
110 __entry->work = work;
111 __entry->function = work->func;
112 ),
113
114 TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
115 );
116
117 /**
118 * sched_kthread_work_execute_end - called immediately after the work callback
119 * @work: pointer to struct work_struct
120 * @function: pointer to worker function
121 *
122 * Allows to track workqueue execution.
123 */
124 TRACE_EVENT(sched_kthread_work_execute_end,
125
126 TP_PROTO(struct kthread_work *work, kthread_work_func_t function),
127
128 TP_ARGS(work, function),
129
130 TP_STRUCT__entry(
131 __field( void *, work )
132 __field( void *, function)
133 ),
134
135 TP_fast_assign(
136 __entry->work = work;
137 __entry->function = function;
138 ),
139
140 TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
141 );
142
143 /*
144 * Tracepoint for waking up a task:
145 */
146 DECLARE_EVENT_CLASS(sched_wakeup_template,
147
148 TP_PROTO(struct task_struct *p),
149
150 TP_ARGS(__perf_task(p)),
151
152 TP_STRUCT__entry(
153 __array( char, comm, TASK_COMM_LEN )
154 __field( pid_t, pid )
155 __field( int, prio )
156 __field( int, target_cpu )
157 ),
158
159 TP_fast_assign(
160 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
161 __entry->pid = p->pid;
162 __entry->prio = p->prio; /* XXX SCHED_DEADLINE */
163 __entry->target_cpu = task_cpu(p);
164 ),
165
166 TP_printk("comm=%s pid=%d prio=%d target_cpu=%03d",
167 __entry->comm, __entry->pid, __entry->prio,
168 __entry->target_cpu)
169 );
170
171 /*
172 * Tracepoint called when waking a task; this tracepoint is guaranteed to be
173 * called from the waking context.
174 */
175 DEFINE_EVENT(sched_wakeup_template, sched_waking,
176 TP_PROTO(struct task_struct *p),
177 TP_ARGS(p));
178
179 /*
180 * Tracepoint called when the task is actually woken; p->state == TASK_RUNNING.
181 * It is not always called from the waking context.
182 */
183 DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
184 TP_PROTO(struct task_struct *p),
185 TP_ARGS(p));
186
187 /*
188 * Tracepoint for waking up a new task:
189 */
190 DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
191 TP_PROTO(struct task_struct *p),
192 TP_ARGS(p));
193
194 #ifdef CREATE_TRACE_POINTS
__trace_sched_switch_state(bool preempt,unsigned int prev_state,struct task_struct * p)195 static inline long __trace_sched_switch_state(bool preempt,
196 unsigned int prev_state,
197 struct task_struct *p)
198 {
199 unsigned int state;
200
201 #ifdef CONFIG_SCHED_DEBUG
202 BUG_ON(p != current);
203 #endif /* CONFIG_SCHED_DEBUG */
204
205 /*
206 * Preemption ignores task state, therefore preempted tasks are always
207 * RUNNING (we will not have dequeued if state != RUNNING).
208 */
209 if (preempt)
210 return TASK_REPORT_MAX;
211
212 /*
213 * task_state_index() uses fls() and returns a value from 0-8 range.
214 * Decrement it by 1 (except TASK_RUNNING state i.e 0) before using
215 * it for left shift operation to get the correct task->state
216 * mapping.
217 */
218 state = __task_state_index(prev_state, p->exit_state);
219
220 return state ? (1 << (state - 1)) : state;
221 }
222 #endif /* CREATE_TRACE_POINTS */
223
224 /*
225 * Tracepoint for task switches, performed by the scheduler:
226 */
227 TRACE_EVENT(sched_switch,
228
229 TP_PROTO(bool preempt,
230 struct task_struct *prev,
231 struct task_struct *next,
232 unsigned int prev_state),
233
234 TP_ARGS(preempt, prev, next, prev_state),
235
236 TP_STRUCT__entry(
237 __array( char, prev_comm, TASK_COMM_LEN )
238 __field( pid_t, prev_pid )
239 __field( int, prev_prio )
240 __field( long, prev_state )
241 __array( char, next_comm, TASK_COMM_LEN )
242 __field( pid_t, next_pid )
243 __field( int, next_prio )
244 ),
245
246 TP_fast_assign(
247 memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
248 __entry->prev_pid = prev->pid;
249 __entry->prev_prio = prev->prio;
250 __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev);
251 memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
252 __entry->next_pid = next->pid;
253 __entry->next_prio = next->prio;
254 /* XXX SCHED_DEADLINE */
255 ),
256
257 TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
258 __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
259
260 (__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
261 __print_flags(__entry->prev_state & (TASK_REPORT_MAX - 1), "|",
262 { TASK_INTERRUPTIBLE, "S" },
263 { TASK_UNINTERRUPTIBLE, "D" },
264 { __TASK_STOPPED, "T" },
265 { __TASK_TRACED, "t" },
266 { EXIT_DEAD, "X" },
267 { EXIT_ZOMBIE, "Z" },
268 { TASK_PARKED, "P" },
269 { TASK_DEAD, "I" }) :
270 "R",
271
272 __entry->prev_state & TASK_REPORT_MAX ? "+" : "",
273 __entry->next_comm, __entry->next_pid, __entry->next_prio)
274 );
275
276 /*
277 * Tracepoint for a task being migrated:
278 */
279 TRACE_EVENT(sched_migrate_task,
280
281 TP_PROTO(struct task_struct *p, int dest_cpu),
282
283 TP_ARGS(p, dest_cpu),
284
285 TP_STRUCT__entry(
286 __array( char, comm, TASK_COMM_LEN )
287 __field( pid_t, pid )
288 __field( int, prio )
289 __field( int, orig_cpu )
290 __field( int, dest_cpu )
291 ),
292
293 TP_fast_assign(
294 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
295 __entry->pid = p->pid;
296 __entry->prio = p->prio; /* XXX SCHED_DEADLINE */
297 __entry->orig_cpu = task_cpu(p);
298 __entry->dest_cpu = dest_cpu;
299 ),
300
301 TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d",
302 __entry->comm, __entry->pid, __entry->prio,
303 __entry->orig_cpu, __entry->dest_cpu)
304 );
305
306 DECLARE_EVENT_CLASS(sched_process_template,
307
308 TP_PROTO(struct task_struct *p),
309
310 TP_ARGS(p),
311
312 TP_STRUCT__entry(
313 __array( char, comm, TASK_COMM_LEN )
314 __field( pid_t, pid )
315 __field( int, prio )
316 ),
317
318 TP_fast_assign(
319 memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
320 __entry->pid = p->pid;
321 __entry->prio = p->prio; /* XXX SCHED_DEADLINE */
322 ),
323
324 TP_printk("comm=%s pid=%d prio=%d",
325 __entry->comm, __entry->pid, __entry->prio)
326 );
327
328 /*
329 * Tracepoint for freeing a task:
330 */
331 DEFINE_EVENT(sched_process_template, sched_process_free,
332 TP_PROTO(struct task_struct *p),
333 TP_ARGS(p));
334
335 /*
336 * Tracepoint for a task exiting:
337 */
338 DEFINE_EVENT(sched_process_template, sched_process_exit,
339 TP_PROTO(struct task_struct *p),
340 TP_ARGS(p));
341
342 /*
343 * Tracepoint for waiting on task to unschedule:
344 */
345 DEFINE_EVENT(sched_process_template, sched_wait_task,
346 TP_PROTO(struct task_struct *p),
347 TP_ARGS(p));
348
349 /*
350 * Tracepoint for a waiting task:
351 */
352 TRACE_EVENT(sched_process_wait,
353
354 TP_PROTO(struct pid *pid),
355
356 TP_ARGS(pid),
357
358 TP_STRUCT__entry(
359 __array( char, comm, TASK_COMM_LEN )
360 __field( pid_t, pid )
361 __field( int, prio )
362 ),
363
364 TP_fast_assign(
365 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
366 __entry->pid = pid_nr(pid);
367 __entry->prio = current->prio; /* XXX SCHED_DEADLINE */
368 ),
369
370 TP_printk("comm=%s pid=%d prio=%d",
371 __entry->comm, __entry->pid, __entry->prio)
372 );
373
374 /*
375 * Tracepoint for kernel_clone:
376 */
377 TRACE_EVENT(sched_process_fork,
378
379 TP_PROTO(struct task_struct *parent, struct task_struct *child),
380
381 TP_ARGS(parent, child),
382
383 TP_STRUCT__entry(
384 __array( char, parent_comm, TASK_COMM_LEN )
385 __field( pid_t, parent_pid )
386 __array( char, child_comm, TASK_COMM_LEN )
387 __field( pid_t, child_pid )
388 ),
389
390 TP_fast_assign(
391 memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
392 __entry->parent_pid = parent->pid;
393 memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
394 __entry->child_pid = child->pid;
395 ),
396
397 TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
398 __entry->parent_comm, __entry->parent_pid,
399 __entry->child_comm, __entry->child_pid)
400 );
401
402 /*
403 * Tracepoint for exec:
404 */
405 TRACE_EVENT(sched_process_exec,
406
407 TP_PROTO(struct task_struct *p, pid_t old_pid,
408 struct linux_binprm *bprm),
409
410 TP_ARGS(p, old_pid, bprm),
411
412 TP_STRUCT__entry(
413 __string( filename, bprm->filename )
414 __field( pid_t, pid )
415 __field( pid_t, old_pid )
416 ),
417
418 TP_fast_assign(
419 __assign_str(filename, bprm->filename);
420 __entry->pid = p->pid;
421 __entry->old_pid = old_pid;
422 ),
423
424 TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
425 __entry->pid, __entry->old_pid)
426 );
427
428
429 #ifdef CONFIG_SCHEDSTATS
430 #define DEFINE_EVENT_SCHEDSTAT DEFINE_EVENT
431 #define DECLARE_EVENT_CLASS_SCHEDSTAT DECLARE_EVENT_CLASS
432 #else
433 #define DEFINE_EVENT_SCHEDSTAT DEFINE_EVENT_NOP
434 #define DECLARE_EVENT_CLASS_SCHEDSTAT DECLARE_EVENT_CLASS_NOP
435 #endif
436
437 /*
438 * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
439 * adding sched_stat support to SCHED_FIFO/RR would be welcome.
440 */
441 DECLARE_EVENT_CLASS_SCHEDSTAT(sched_stat_template,
442
443 TP_PROTO(struct task_struct *tsk, u64 delay),
444
445 TP_ARGS(__perf_task(tsk), __perf_count(delay)),
446
447 TP_STRUCT__entry(
448 __array( char, comm, TASK_COMM_LEN )
449 __field( pid_t, pid )
450 __field( u64, delay )
451 ),
452
453 TP_fast_assign(
454 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
455 __entry->pid = tsk->pid;
456 __entry->delay = delay;
457 ),
458
459 TP_printk("comm=%s pid=%d delay=%Lu [ns]",
460 __entry->comm, __entry->pid,
461 (unsigned long long)__entry->delay)
462 );
463
464 /*
465 * Tracepoint for accounting wait time (time the task is runnable
466 * but not actually running due to scheduler contention).
467 */
468 DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_wait,
469 TP_PROTO(struct task_struct *tsk, u64 delay),
470 TP_ARGS(tsk, delay));
471
472 /*
473 * Tracepoint for accounting sleep time (time the task is not runnable,
474 * including iowait, see below).
475 */
476 DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_sleep,
477 TP_PROTO(struct task_struct *tsk, u64 delay),
478 TP_ARGS(tsk, delay));
479
480 /*
481 * Tracepoint for accounting iowait time (time the task is not runnable
482 * due to waiting on IO to complete).
483 */
484 DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_iowait,
485 TP_PROTO(struct task_struct *tsk, u64 delay),
486 TP_ARGS(tsk, delay));
487
488 /*
489 * Tracepoint for accounting blocked time (time the task is in uninterruptible).
490 */
491 DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_blocked,
492 TP_PROTO(struct task_struct *tsk, u64 delay),
493 TP_ARGS(tsk, delay));
494
495 /*
496 * Tracepoint for accounting runtime (time the task is executing
497 * on a CPU).
498 */
499 DECLARE_EVENT_CLASS(sched_stat_runtime,
500
501 TP_PROTO(struct task_struct *tsk, u64 runtime),
502
503 TP_ARGS(tsk, __perf_count(runtime)),
504
505 TP_STRUCT__entry(
506 __array( char, comm, TASK_COMM_LEN )
507 __field( pid_t, pid )
508 __field( u64, runtime )
509 ),
510
511 TP_fast_assign(
512 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
513 __entry->pid = tsk->pid;
514 __entry->runtime = runtime;
515 ),
516
517 TP_printk("comm=%s pid=%d runtime=%Lu [ns]",
518 __entry->comm, __entry->pid,
519 (unsigned long long)__entry->runtime)
520 );
521
522 DEFINE_EVENT(sched_stat_runtime, sched_stat_runtime,
523 TP_PROTO(struct task_struct *tsk, u64 runtime),
524 TP_ARGS(tsk, runtime));
525
526 /*
527 * Tracepoint for showing priority inheritance modifying a tasks
528 * priority.
529 */
530 TRACE_EVENT(sched_pi_setprio,
531
532 TP_PROTO(struct task_struct *tsk, struct task_struct *pi_task),
533
534 TP_ARGS(tsk, pi_task),
535
536 TP_STRUCT__entry(
537 __array( char, comm, TASK_COMM_LEN )
538 __field( pid_t, pid )
539 __field( int, oldprio )
540 __field( int, newprio )
541 ),
542
543 TP_fast_assign(
544 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
545 __entry->pid = tsk->pid;
546 __entry->oldprio = tsk->prio;
547 __entry->newprio = pi_task ?
548 min(tsk->normal_prio, pi_task->prio) :
549 tsk->normal_prio;
550 /* XXX SCHED_DEADLINE bits missing */
551 ),
552
553 TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
554 __entry->comm, __entry->pid,
555 __entry->oldprio, __entry->newprio)
556 );
557
558 #ifdef CONFIG_DETECT_HUNG_TASK
559 TRACE_EVENT(sched_process_hang,
560 TP_PROTO(struct task_struct *tsk),
561 TP_ARGS(tsk),
562
563 TP_STRUCT__entry(
564 __array( char, comm, TASK_COMM_LEN )
565 __field( pid_t, pid )
566 ),
567
568 TP_fast_assign(
569 memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
570 __entry->pid = tsk->pid;
571 ),
572
573 TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
574 );
575 #endif /* CONFIG_DETECT_HUNG_TASK */
576
577 /*
578 * Tracks migration of tasks from one runqueue to another. Can be used to
579 * detect if automatic NUMA balancing is bouncing between nodes.
580 */
581 TRACE_EVENT(sched_move_numa,
582
583 TP_PROTO(struct task_struct *tsk, int src_cpu, int dst_cpu),
584
585 TP_ARGS(tsk, src_cpu, dst_cpu),
586
587 TP_STRUCT__entry(
588 __field( pid_t, pid )
589 __field( pid_t, tgid )
590 __field( pid_t, ngid )
591 __field( int, src_cpu )
592 __field( int, src_nid )
593 __field( int, dst_cpu )
594 __field( int, dst_nid )
595 ),
596
597 TP_fast_assign(
598 __entry->pid = task_pid_nr(tsk);
599 __entry->tgid = task_tgid_nr(tsk);
600 __entry->ngid = task_numa_group_id(tsk);
601 __entry->src_cpu = src_cpu;
602 __entry->src_nid = cpu_to_node(src_cpu);
603 __entry->dst_cpu = dst_cpu;
604 __entry->dst_nid = cpu_to_node(dst_cpu);
605 ),
606
607 TP_printk("pid=%d tgid=%d ngid=%d src_cpu=%d src_nid=%d dst_cpu=%d dst_nid=%d",
608 __entry->pid, __entry->tgid, __entry->ngid,
609 __entry->src_cpu, __entry->src_nid,
610 __entry->dst_cpu, __entry->dst_nid)
611 );
612
613 DECLARE_EVENT_CLASS(sched_numa_pair_template,
614
615 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
616 struct task_struct *dst_tsk, int dst_cpu),
617
618 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu),
619
620 TP_STRUCT__entry(
621 __field( pid_t, src_pid )
622 __field( pid_t, src_tgid )
623 __field( pid_t, src_ngid )
624 __field( int, src_cpu )
625 __field( int, src_nid )
626 __field( pid_t, dst_pid )
627 __field( pid_t, dst_tgid )
628 __field( pid_t, dst_ngid )
629 __field( int, dst_cpu )
630 __field( int, dst_nid )
631 ),
632
633 TP_fast_assign(
634 __entry->src_pid = task_pid_nr(src_tsk);
635 __entry->src_tgid = task_tgid_nr(src_tsk);
636 __entry->src_ngid = task_numa_group_id(src_tsk);
637 __entry->src_cpu = src_cpu;
638 __entry->src_nid = cpu_to_node(src_cpu);
639 __entry->dst_pid = dst_tsk ? task_pid_nr(dst_tsk) : 0;
640 __entry->dst_tgid = dst_tsk ? task_tgid_nr(dst_tsk) : 0;
641 __entry->dst_ngid = dst_tsk ? task_numa_group_id(dst_tsk) : 0;
642 __entry->dst_cpu = dst_cpu;
643 __entry->dst_nid = dst_cpu >= 0 ? cpu_to_node(dst_cpu) : -1;
644 ),
645
646 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",
647 __entry->src_pid, __entry->src_tgid, __entry->src_ngid,
648 __entry->src_cpu, __entry->src_nid,
649 __entry->dst_pid, __entry->dst_tgid, __entry->dst_ngid,
650 __entry->dst_cpu, __entry->dst_nid)
651 );
652
653 DEFINE_EVENT(sched_numa_pair_template, sched_stick_numa,
654
655 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
656 struct task_struct *dst_tsk, int dst_cpu),
657
658 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu)
659 );
660
661 DEFINE_EVENT(sched_numa_pair_template, sched_swap_numa,
662
663 TP_PROTO(struct task_struct *src_tsk, int src_cpu,
664 struct task_struct *dst_tsk, int dst_cpu),
665
666 TP_ARGS(src_tsk, src_cpu, dst_tsk, dst_cpu)
667 );
668
669 #ifdef CONFIG_NUMA_BALANCING
670 #define NUMAB_SKIP_REASON \
671 EM( NUMAB_SKIP_UNSUITABLE, "unsuitable" ) \
672 EM( NUMAB_SKIP_SHARED_RO, "shared_ro" ) \
673 EM( NUMAB_SKIP_INACCESSIBLE, "inaccessible" ) \
674 EM( NUMAB_SKIP_SCAN_DELAY, "scan_delay" ) \
675 EM( NUMAB_SKIP_PID_INACTIVE, "pid_inactive" ) \
676 EM( NUMAB_SKIP_IGNORE_PID, "ignore_pid_inactive" ) \
677 EMe(NUMAB_SKIP_SEQ_COMPLETED, "seq_completed" )
678
679 /* Redefine for export. */
680 #undef EM
681 #undef EMe
682 #define EM(a, b) TRACE_DEFINE_ENUM(a);
683 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
684
685 NUMAB_SKIP_REASON
686
687 /* Redefine for symbolic printing. */
688 #undef EM
689 #undef EMe
690 #define EM(a, b) { a, b },
691 #define EMe(a, b) { a, b }
692
693 TRACE_EVENT(sched_skip_vma_numa,
694
695 TP_PROTO(struct mm_struct *mm, struct vm_area_struct *vma,
696 enum numa_vmaskip_reason reason),
697
698 TP_ARGS(mm, vma, reason),
699
700 TP_STRUCT__entry(
701 __field(unsigned long, numa_scan_offset)
702 __field(unsigned long, vm_start)
703 __field(unsigned long, vm_end)
704 __field(enum numa_vmaskip_reason, reason)
705 ),
706
707 TP_fast_assign(
708 __entry->numa_scan_offset = mm->numa_scan_offset;
709 __entry->vm_start = vma->vm_start;
710 __entry->vm_end = vma->vm_end;
711 __entry->reason = reason;
712 ),
713
714 TP_printk("numa_scan_offset=%lX vm_start=%lX vm_end=%lX reason=%s",
715 __entry->numa_scan_offset,
716 __entry->vm_start,
717 __entry->vm_end,
718 __print_symbolic(__entry->reason, NUMAB_SKIP_REASON))
719 );
720 #endif /* CONFIG_NUMA_BALANCING */
721
722 /*
723 * Tracepoint for waking a polling cpu without an IPI.
724 */
725 TRACE_EVENT(sched_wake_idle_without_ipi,
726
727 TP_PROTO(int cpu),
728
729 TP_ARGS(cpu),
730
731 TP_STRUCT__entry(
732 __field( int, cpu )
733 ),
734
735 TP_fast_assign(
736 __entry->cpu = cpu;
737 ),
738
739 TP_printk("cpu=%d", __entry->cpu)
740 );
741
742 #ifdef CONFIG_SCHED_CORE_CTRL
743 TRACE_EVENT(core_ctl_eval_need,
744
745 TP_PROTO(unsigned int cpu, unsigned int old_need,
746 unsigned int new_need, unsigned int updated),
747 TP_ARGS(cpu, old_need, new_need, updated),
748 TP_STRUCT__entry(
749 __field(u32, cpu)
750 __field(u32, old_need)
751 __field(u32, new_need)
752 __field(u32, updated)
753 ),
754 TP_fast_assign(
755 __entry->cpu = cpu;
756 __entry->old_need = old_need;
757 __entry->new_need = new_need;
758 __entry->updated = updated;
759 ),
760 TP_printk("cpu=%u, old_need=%u, new_need=%u, updated=%u", __entry->cpu,
761 __entry->old_need, __entry->new_need, __entry->updated)
762 );
763
764 TRACE_EVENT(core_ctl_set_busy,
765
766 TP_PROTO(unsigned int cpu, unsigned int busy,
767 unsigned int old_is_busy, unsigned int is_busy, int high_irqload),
768 TP_ARGS(cpu, busy, old_is_busy, is_busy, high_irqload),
769 TP_STRUCT__entry(
770 __field(u32, cpu)
771 __field(u32, busy)
772 __field(u32, old_is_busy)
773 __field(u32, is_busy)
774 __field(bool, high_irqload)
775 ),
776 TP_fast_assign(
777 __entry->cpu = cpu;
778 __entry->busy = busy;
779 __entry->old_is_busy = old_is_busy;
780 __entry->is_busy = is_busy;
781 __entry->high_irqload = high_irqload;
782 ),
783 TP_printk("cpu=%u, busy=%u, old_is_busy=%u, new_is_busy=%u high_irqload=%d",
784 __entry->cpu, __entry->busy, __entry->old_is_busy,
785 __entry->is_busy, __entry->high_irqload)
786 );
787
788 TRACE_EVENT(core_ctl_set_boost,
789
790 TP_PROTO(u32 refcount, s32 ret),
791 TP_ARGS(refcount, ret),
792 TP_STRUCT__entry(
793 __field(u32, refcount)
794 __field(s32, ret)
795 ),
796 TP_fast_assign(
797 __entry->refcount = refcount;
798 __entry->ret = ret;
799 ),
800 TP_printk("refcount=%u, ret=%d", __entry->refcount, __entry->ret)
801 );
802
803 TRACE_EVENT(core_ctl_update_nr_need,
804
805 TP_PROTO(int cpu, int nr_need, int prev_misfit_need,
806 int nrrun, int max_nr, int nr_prev_assist),
807
808 TP_ARGS(cpu, nr_need, prev_misfit_need, nrrun, max_nr, nr_prev_assist),
809
810 TP_STRUCT__entry(
811 __field(int, cpu)
812 __field(int, nr_need)
813 __field(int, prev_misfit_need)
814 __field(int, nrrun)
815 __field(int, max_nr)
816 __field(int, nr_prev_assist)
817 ),
818
819 TP_fast_assign(
820 __entry->cpu = cpu;
821 __entry->nr_need = nr_need;
822 __entry->prev_misfit_need = prev_misfit_need;
823 __entry->nrrun = nrrun;
824 __entry->max_nr = max_nr;
825 __entry->nr_prev_assist = nr_prev_assist;
826 ),
827
828 TP_printk("cpu=%d nr_need=%d prev_misfit_need=%d nrrun=%d max_nr=%d nr_prev_assist=%d",
829 __entry->cpu, __entry->nr_need, __entry->prev_misfit_need,
830 __entry->nrrun, __entry->max_nr, __entry->nr_prev_assist)
831 );
832 #endif
833
834 #ifdef CONFIG_SCHED_RUNNING_AVG
835 /*
836 * Tracepoint for sched_get_nr_running_avg
837 */
838 TRACE_EVENT(sched_get_nr_running_avg,
839
840 TP_PROTO(int cpu, int nr, int nr_misfit, int nr_max),
841
842 TP_ARGS(cpu, nr, nr_misfit, nr_max),
843
844 TP_STRUCT__entry(
845 __field(int, cpu)
846 __field(int, nr)
847 __field(int, nr_misfit)
848 __field(int, nr_max)
849 ),
850
851 TP_fast_assign(
852 __entry->cpu = cpu;
853 __entry->nr = nr;
854 __entry->nr_misfit = nr_misfit;
855 __entry->nr_max = nr_max;
856 ),
857
858 TP_printk("cpu=%d nr=%d nr_misfit=%d nr_max=%d",
859 __entry->cpu, __entry->nr, __entry->nr_misfit, __entry->nr_max)
860 );
861 #endif
862
863 #ifdef CONFIG_CPU_ISOLATION_OPT
864 /*
865 * sched_isolate - called when cores are isolated/unisolated
866 *
867 * @acutal_mask: mask of cores actually isolated/unisolated
868 * @req_mask: mask of cores requested isolated/unisolated
869 * @online_mask: cpu online mask
870 * @time: amount of time in us it took to isolate/unisolate
871 * @isolate: 1 if isolating, 0 if unisolating
872 *
873 */
874 TRACE_EVENT(sched_isolate,
875
876 TP_PROTO(unsigned int requested_cpu, unsigned int isolated_cpus,
877 u64 start_time, unsigned char isolate),
878
879 TP_ARGS(requested_cpu, isolated_cpus, start_time, isolate),
880
881 TP_STRUCT__entry(
882 __field(u32, requested_cpu)
883 __field(u32, isolated_cpus)
884 __field(u32, time)
885 __field(unsigned char, isolate)
886 ),
887
888 TP_fast_assign(
889 __entry->requested_cpu = requested_cpu;
890 __entry->isolated_cpus = isolated_cpus;
891 __entry->time = div64_u64(sched_clock() - start_time, 1000);
892 __entry->isolate = isolate;
893 ),
894
895 TP_printk("iso cpu=%u cpus=0x%x time=%u us isolated=%d",
896 __entry->requested_cpu, __entry->isolated_cpus,
897 __entry->time, __entry->isolate)
898 );
899 #endif
900
901 /*
902 * Following tracepoints are not exported in tracefs and provide hooking
903 * mechanisms only for testing and debugging purposes.
904 *
905 * Postfixed with _tp to make them easily identifiable in the code.
906 */
907 DECLARE_TRACE(pelt_cfs_tp,
908 TP_PROTO(struct cfs_rq *cfs_rq),
909 TP_ARGS(cfs_rq));
910
911 DECLARE_TRACE(pelt_rt_tp,
912 TP_PROTO(struct rq *rq),
913 TP_ARGS(rq));
914
915 DECLARE_TRACE(pelt_dl_tp,
916 TP_PROTO(struct rq *rq),
917 TP_ARGS(rq));
918
919 DECLARE_TRACE(pelt_thermal_tp,
920 TP_PROTO(struct rq *rq),
921 TP_ARGS(rq));
922
923 DECLARE_TRACE(pelt_irq_tp,
924 TP_PROTO(struct rq *rq),
925 TP_ARGS(rq));
926
927 DECLARE_TRACE(pelt_se_tp,
928 TP_PROTO(struct sched_entity *se),
929 TP_ARGS(se));
930
931 DECLARE_TRACE(sched_cpu_capacity_tp,
932 TP_PROTO(struct rq *rq),
933 TP_ARGS(rq));
934
935 DECLARE_TRACE(sched_overutilized_tp,
936 TP_PROTO(struct root_domain *rd, bool overutilized),
937 TP_ARGS(rd, overutilized));
938
939 DECLARE_TRACE(sched_util_est_cfs_tp,
940 TP_PROTO(struct cfs_rq *cfs_rq),
941 TP_ARGS(cfs_rq));
942
943 DECLARE_TRACE(sched_util_est_se_tp,
944 TP_PROTO(struct sched_entity *se),
945 TP_ARGS(se));
946
947 DECLARE_TRACE(sched_update_nr_running_tp,
948 TP_PROTO(struct rq *rq, int change),
949 TP_ARGS(rq, change));
950
951 #endif /* _TRACE_SCHED_H */
952
953 /* This part must be outside protection */
954 #include <trace/define_trace.h>
955