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