aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_sched_wakeup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_sched_wakeup.c')
-rw-r--r--kernel/trace/trace_sched_wakeup.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index fee77e15d815..090c4d9dcf16 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -27,6 +27,8 @@ static int wakeup_cpu;
27static int wakeup_current_cpu; 27static int wakeup_current_cpu;
28static unsigned wakeup_prio = -1; 28static unsigned wakeup_prio = -1;
29static int wakeup_rt; 29static int wakeup_rt;
30static int wakeup_dl;
31static int tracing_dl = 0;
30 32
31static arch_spinlock_t wakeup_lock = 33static arch_spinlock_t wakeup_lock =
32 (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; 34 (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
@@ -437,6 +439,7 @@ static void __wakeup_reset(struct trace_array *tr)
437{ 439{
438 wakeup_cpu = -1; 440 wakeup_cpu = -1;
439 wakeup_prio = -1; 441 wakeup_prio = -1;
442 tracing_dl = 0;
440 443
441 if (wakeup_task) 444 if (wakeup_task)
442 put_task_struct(wakeup_task); 445 put_task_struct(wakeup_task);
@@ -472,9 +475,17 @@ probe_wakeup(void *ignore, struct task_struct *p, int success)
472 tracing_record_cmdline(p); 475 tracing_record_cmdline(p);
473 tracing_record_cmdline(current); 476 tracing_record_cmdline(current);
474 477
475 if ((wakeup_rt && !rt_task(p)) || 478 /*
476 p->prio >= wakeup_prio || 479 * Semantic is like this:
477 p->prio >= current->prio) 480 * - wakeup tracer handles all tasks in the system, independently
481 * from their scheduling class;
482 * - wakeup_rt tracer handles tasks belonging to sched_dl and
483 * sched_rt class;
484 * - wakeup_dl handles tasks belonging to sched_dl class only.
485 */
486 if (tracing_dl || (wakeup_dl && !dl_task(p)) ||
487 (wakeup_rt && !dl_task(p) && !rt_task(p)) ||
488 (!dl_task(p) && (p->prio >= wakeup_prio || p->prio >= current->prio)))
478 return; 489 return;
479 490
480 pc = preempt_count(); 491 pc = preempt_count();
@@ -486,7 +497,8 @@ probe_wakeup(void *ignore, struct task_struct *p, int success)
486 arch_spin_lock(&wakeup_lock); 497 arch_spin_lock(&wakeup_lock);
487 498
488 /* check for races. */ 499 /* check for races. */
489 if (!tracer_enabled || p->prio >= wakeup_prio) 500 if (!tracer_enabled || tracing_dl ||
501 (!dl_task(p) && p->prio >= wakeup_prio))
490 goto out_locked; 502 goto out_locked;
491 503
492 /* reset the trace */ 504 /* reset the trace */
@@ -496,6 +508,15 @@ probe_wakeup(void *ignore, struct task_struct *p, int success)
496 wakeup_current_cpu = wakeup_cpu; 508 wakeup_current_cpu = wakeup_cpu;
497 wakeup_prio = p->prio; 509 wakeup_prio = p->prio;
498 510
511 /*
512 * Once you start tracing a -deadline task, don't bother tracing
513 * another task until the first one wakes up.
514 */
515 if (dl_task(p))
516 tracing_dl = 1;
517 else
518 tracing_dl = 0;
519
499 wakeup_task = p; 520 wakeup_task = p;
500 get_task_struct(wakeup_task); 521 get_task_struct(wakeup_task);
501 522
@@ -597,16 +618,25 @@ static int __wakeup_tracer_init(struct trace_array *tr)
597 618
598static int wakeup_tracer_init(struct trace_array *tr) 619static int wakeup_tracer_init(struct trace_array *tr)
599{ 620{
621 wakeup_dl = 0;
600 wakeup_rt = 0; 622 wakeup_rt = 0;
601 return __wakeup_tracer_init(tr); 623 return __wakeup_tracer_init(tr);
602} 624}
603 625
604static int wakeup_rt_tracer_init(struct trace_array *tr) 626static int wakeup_rt_tracer_init(struct trace_array *tr)
605{ 627{
628 wakeup_dl = 0;
606 wakeup_rt = 1; 629 wakeup_rt = 1;
607 return __wakeup_tracer_init(tr); 630 return __wakeup_tracer_init(tr);
608} 631}
609 632
633static int wakeup_dl_tracer_init(struct trace_array *tr)
634{
635 wakeup_dl = 1;
636 wakeup_rt = 0;
637 return __wakeup_tracer_init(tr);
638}
639
610static void wakeup_tracer_reset(struct trace_array *tr) 640static void wakeup_tracer_reset(struct trace_array *tr)
611{ 641{
612 int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; 642 int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
@@ -674,6 +704,28 @@ static struct tracer wakeup_rt_tracer __read_mostly =
674 .use_max_tr = true, 704 .use_max_tr = true,
675}; 705};
676 706
707static struct tracer wakeup_dl_tracer __read_mostly =
708{
709 .name = "wakeup_dl",
710 .init = wakeup_dl_tracer_init,
711 .reset = wakeup_tracer_reset,
712 .start = wakeup_tracer_start,
713 .stop = wakeup_tracer_stop,
714 .wait_pipe = poll_wait_pipe,
715 .print_max = true,
716 .print_header = wakeup_print_header,
717 .print_line = wakeup_print_line,
718 .flags = &tracer_flags,
719 .set_flag = wakeup_set_flag,
720 .flag_changed = wakeup_flag_changed,
721#ifdef CONFIG_FTRACE_SELFTEST
722 .selftest = trace_selftest_startup_wakeup,
723#endif
724 .open = wakeup_trace_open,
725 .close = wakeup_trace_close,
726 .use_max_tr = true,
727};
728
677__init static int init_wakeup_tracer(void) 729__init static int init_wakeup_tracer(void)
678{ 730{
679 int ret; 731 int ret;
@@ -686,6 +738,10 @@ __init static int init_wakeup_tracer(void)
686 if (ret) 738 if (ret)
687 return ret; 739 return ret;
688 740
741 ret = register_tracer(&wakeup_dl_tracer);
742 if (ret)
743 return ret;
744
689 return 0; 745 return 0;
690} 746}
691core_initcall(init_wakeup_tracer); 747core_initcall(init_wakeup_tracer);