diff options
Diffstat (limited to 'tools/perf/builtin-sched.c')
| -rw-r--r-- | tools/perf/builtin-sched.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index b94cf0de715a..b92c4d97192c 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
| @@ -221,6 +221,7 @@ struct perf_sched { | |||
| 221 | unsigned int max_stack; | 221 | unsigned int max_stack; |
| 222 | bool show_cpu_visual; | 222 | bool show_cpu_visual; |
| 223 | bool show_wakeups; | 223 | bool show_wakeups; |
| 224 | bool show_next; | ||
| 224 | bool show_migrations; | 225 | bool show_migrations; |
| 225 | bool show_state; | 226 | bool show_state; |
| 226 | u64 skipped_samples; | 227 | u64 skipped_samples; |
| @@ -1897,14 +1898,18 @@ static char task_state_char(struct thread *thread, int state) | |||
| 1897 | } | 1898 | } |
| 1898 | 1899 | ||
| 1899 | static void timehist_print_sample(struct perf_sched *sched, | 1900 | static void timehist_print_sample(struct perf_sched *sched, |
| 1901 | struct perf_evsel *evsel, | ||
| 1900 | struct perf_sample *sample, | 1902 | struct perf_sample *sample, |
| 1901 | struct addr_location *al, | 1903 | struct addr_location *al, |
| 1902 | struct thread *thread, | 1904 | struct thread *thread, |
| 1903 | u64 t, int state) | 1905 | u64 t, int state) |
| 1904 | { | 1906 | { |
| 1905 | struct thread_runtime *tr = thread__priv(thread); | 1907 | struct thread_runtime *tr = thread__priv(thread); |
| 1908 | const char *next_comm = perf_evsel__strval(evsel, sample, "next_comm"); | ||
| 1909 | const u32 next_pid = perf_evsel__intval(evsel, sample, "next_pid"); | ||
| 1906 | u32 max_cpus = sched->max_cpu + 1; | 1910 | u32 max_cpus = sched->max_cpu + 1; |
| 1907 | char tstr[64]; | 1911 | char tstr[64]; |
| 1912 | char nstr[30]; | ||
| 1908 | u64 wait_time; | 1913 | u64 wait_time; |
| 1909 | 1914 | ||
| 1910 | timestamp__scnprintf_usec(t, tstr, sizeof(tstr)); | 1915 | timestamp__scnprintf_usec(t, tstr, sizeof(tstr)); |
| @@ -1937,7 +1942,12 @@ static void timehist_print_sample(struct perf_sched *sched, | |||
| 1937 | if (sched->show_state) | 1942 | if (sched->show_state) |
| 1938 | printf(" %5c ", task_state_char(thread, state)); | 1943 | printf(" %5c ", task_state_char(thread, state)); |
| 1939 | 1944 | ||
| 1940 | if (sched->show_wakeups) | 1945 | if (sched->show_next) { |
| 1946 | snprintf(nstr, sizeof(nstr), "next: %s[%d]", next_comm, next_pid); | ||
| 1947 | printf(" %-*s", comm_width, nstr); | ||
| 1948 | } | ||
| 1949 | |||
| 1950 | if (sched->show_wakeups && !sched->show_next) | ||
| 1941 | printf(" %-*s", comm_width, ""); | 1951 | printf(" %-*s", comm_width, ""); |
| 1942 | 1952 | ||
| 1943 | if (thread->tid == 0) | 1953 | if (thread->tid == 0) |
| @@ -2531,7 +2541,7 @@ static int timehist_sched_change_event(struct perf_tool *tool, | |||
| 2531 | } | 2541 | } |
| 2532 | 2542 | ||
| 2533 | if (!sched->summary_only) | 2543 | if (!sched->summary_only) |
| 2534 | timehist_print_sample(sched, sample, &al, thread, t, state); | 2544 | timehist_print_sample(sched, evsel, sample, &al, thread, t, state); |
| 2535 | 2545 | ||
| 2536 | out: | 2546 | out: |
| 2537 | if (sched->hist_time.start == 0 && t >= ptime->start) | 2547 | if (sched->hist_time.start == 0 && t >= ptime->start) |
| @@ -3272,6 +3282,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | |||
| 3272 | .tool = { | 3282 | .tool = { |
| 3273 | .sample = perf_sched__process_tracepoint_sample, | 3283 | .sample = perf_sched__process_tracepoint_sample, |
| 3274 | .comm = perf_event__process_comm, | 3284 | .comm = perf_event__process_comm, |
| 3285 | .namespaces = perf_event__process_namespaces, | ||
| 3275 | .lost = perf_event__process_lost, | 3286 | .lost = perf_event__process_lost, |
| 3276 | .fork = perf_sched__process_fork_event, | 3287 | .fork = perf_sched__process_fork_event, |
| 3277 | .ordered_events = true, | 3288 | .ordered_events = true, |
| @@ -3340,6 +3351,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | |||
| 3340 | OPT_BOOLEAN('S', "with-summary", &sched.summary, | 3351 | OPT_BOOLEAN('S', "with-summary", &sched.summary, |
| 3341 | "Show all syscalls and summary with statistics"), | 3352 | "Show all syscalls and summary with statistics"), |
| 3342 | OPT_BOOLEAN('w', "wakeups", &sched.show_wakeups, "Show wakeup events"), | 3353 | OPT_BOOLEAN('w', "wakeups", &sched.show_wakeups, "Show wakeup events"), |
| 3354 | OPT_BOOLEAN('n', "next", &sched.show_next, "Show next task"), | ||
| 3343 | OPT_BOOLEAN('M', "migrations", &sched.show_migrations, "Show migration events"), | 3355 | OPT_BOOLEAN('M', "migrations", &sched.show_migrations, "Show migration events"), |
| 3344 | OPT_BOOLEAN('V', "cpu-visual", &sched.show_cpu_visual, "Add CPU visual"), | 3356 | OPT_BOOLEAN('V', "cpu-visual", &sched.show_cpu_visual, "Add CPU visual"), |
| 3345 | OPT_BOOLEAN('I', "idle-hist", &sched.idle_hist, "Show idle events only"), | 3357 | OPT_BOOLEAN('I', "idle-hist", &sched.idle_hist, "Show idle events only"), |
| @@ -3437,10 +3449,14 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | |||
| 3437 | if (argc) | 3449 | if (argc) |
| 3438 | usage_with_options(timehist_usage, timehist_options); | 3450 | usage_with_options(timehist_usage, timehist_options); |
| 3439 | } | 3451 | } |
| 3440 | if (sched.show_wakeups && sched.summary_only) { | 3452 | if ((sched.show_wakeups || sched.show_next) && |
| 3441 | pr_err(" Error: -s and -w are mutually exclusive.\n"); | 3453 | sched.summary_only) { |
| 3454 | pr_err(" Error: -s and -[n|w] are mutually exclusive.\n"); | ||
| 3442 | parse_options_usage(timehist_usage, timehist_options, "s", true); | 3455 | parse_options_usage(timehist_usage, timehist_options, "s", true); |
| 3443 | parse_options_usage(NULL, timehist_options, "w", true); | 3456 | if (sched.show_wakeups) |
| 3457 | parse_options_usage(NULL, timehist_options, "w", true); | ||
| 3458 | if (sched.show_next) | ||
| 3459 | parse_options_usage(NULL, timehist_options, "n", true); | ||
| 3444 | return -EINVAL; | 3460 | return -EINVAL; |
| 3445 | } | 3461 | } |
| 3446 | 3462 | ||
