diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-04-12 09:29:30 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-13 09:11:51 -0400 |
commit | cf294f24f8c83bca6aa8e96b5cc4f78bed887f92 (patch) | |
tree | d4f4a1a5db2f4f787745af50ce3ca8ba93210ad6 | |
parent | a151a37a760aab41c115af8d5016e449228e8d2e (diff) |
perf sched map: Color given cpus
Adding --color-cpus option to display selected cpus with background
color (red by default). It helps on navigating through the perf sched
map output.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460467771-26532-8-git-send-email-jolsa@kernel.org
[ Added entry to man page ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/Documentation/perf-sched.txt | 3 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 36 |
2 files changed, 36 insertions, 3 deletions
diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt index 67913de3aee7..58bff6cbc3f3 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt | |||
@@ -57,6 +57,9 @@ OPTIONS for 'perf sched map' | |||
57 | Show only CPUs with activity. Helps visualizing on high core | 57 | Show only CPUs with activity. Helps visualizing on high core |
58 | count systems. | 58 | count systems. |
59 | 59 | ||
60 | --color-cpus:: | ||
61 | Highlight the given cpus. | ||
62 | |||
60 | --color-pids:: | 63 | --color-pids:: |
61 | Highlight the given pids. | 64 | Highlight the given pids. |
62 | 65 | ||
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index b5361a1d20e1..7de04b297c14 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -125,6 +125,7 @@ struct trace_sched_handler { | |||
125 | }; | 125 | }; |
126 | 126 | ||
127 | #define COLOR_PIDS PERF_COLOR_BLUE | 127 | #define COLOR_PIDS PERF_COLOR_BLUE |
128 | #define COLOR_CPUS PERF_COLOR_BG_RED | ||
128 | 129 | ||
129 | struct perf_sched_map { | 130 | struct perf_sched_map { |
130 | DECLARE_BITMAP(comp_cpus_mask, MAX_CPUS); | 131 | DECLARE_BITMAP(comp_cpus_mask, MAX_CPUS); |
@@ -132,6 +133,8 @@ struct perf_sched_map { | |||
132 | bool comp; | 133 | bool comp; |
133 | struct thread_map *color_pids; | 134 | struct thread_map *color_pids; |
134 | const char *color_pids_str; | 135 | const char *color_pids_str; |
136 | struct cpu_map *color_cpus; | ||
137 | const char *color_cpus_str; | ||
135 | }; | 138 | }; |
136 | 139 | ||
137 | struct perf_sched { | 140 | struct perf_sched { |
@@ -1461,14 +1464,18 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, | |||
1461 | int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i; | 1464 | int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i; |
1462 | struct thread *curr_thread = sched->curr_thread[cpu]; | 1465 | struct thread *curr_thread = sched->curr_thread[cpu]; |
1463 | const char *pid_color = color; | 1466 | const char *pid_color = color; |
1467 | const char *cpu_color = color; | ||
1464 | 1468 | ||
1465 | if (curr_thread && thread__has_color(curr_thread)) | 1469 | if (curr_thread && thread__has_color(curr_thread)) |
1466 | pid_color = COLOR_PIDS; | 1470 | pid_color = COLOR_PIDS; |
1467 | 1471 | ||
1472 | if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu)) | ||
1473 | cpu_color = COLOR_CPUS; | ||
1474 | |||
1468 | if (cpu != this_cpu) | 1475 | if (cpu != this_cpu) |
1469 | color_fprintf(stdout, color, " "); | 1476 | color_fprintf(stdout, cpu_color, " "); |
1470 | else | 1477 | else |
1471 | color_fprintf(stdout, color, "*"); | 1478 | color_fprintf(stdout, cpu_color, "*"); |
1472 | 1479 | ||
1473 | if (sched->curr_thread[cpu]) | 1480 | if (sched->curr_thread[cpu]) |
1474 | color_fprintf(stdout, pid_color, "%2s ", sched->curr_thread[cpu]->shortname); | 1481 | color_fprintf(stdout, pid_color, "%2s ", sched->curr_thread[cpu]->shortname); |
@@ -1753,7 +1760,8 @@ static int setup_map_cpus(struct perf_sched *sched) | |||
1753 | 1760 | ||
1754 | if (sched->map.comp) { | 1761 | if (sched->map.comp) { |
1755 | sched->map.comp_cpus = zalloc(sched->max_cpu * sizeof(int)); | 1762 | sched->map.comp_cpus = zalloc(sched->max_cpu * sizeof(int)); |
1756 | return sched->map.comp_cpus ? 0 : -1; | 1763 | if (!sched->map.comp_cpus) |
1764 | return -1; | ||
1757 | } | 1765 | } |
1758 | 1766 | ||
1759 | return 0; | 1767 | return 0; |
@@ -1776,6 +1784,23 @@ static int setup_color_pids(struct perf_sched *sched) | |||
1776 | return 0; | 1784 | return 0; |
1777 | } | 1785 | } |
1778 | 1786 | ||
1787 | static int setup_color_cpus(struct perf_sched *sched) | ||
1788 | { | ||
1789 | struct cpu_map *map; | ||
1790 | |||
1791 | if (!sched->map.color_cpus_str) | ||
1792 | return 0; | ||
1793 | |||
1794 | map = cpu_map__new(sched->map.color_cpus_str); | ||
1795 | if (!map) { | ||
1796 | pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str); | ||
1797 | return -1; | ||
1798 | } | ||
1799 | |||
1800 | sched->map.color_cpus = map; | ||
1801 | return 0; | ||
1802 | } | ||
1803 | |||
1779 | static int perf_sched__map(struct perf_sched *sched) | 1804 | static int perf_sched__map(struct perf_sched *sched) |
1780 | { | 1805 | { |
1781 | if (setup_map_cpus(sched)) | 1806 | if (setup_map_cpus(sched)) |
@@ -1784,6 +1809,9 @@ static int perf_sched__map(struct perf_sched *sched) | |||
1784 | if (setup_color_pids(sched)) | 1809 | if (setup_color_pids(sched)) |
1785 | return -1; | 1810 | return -1; |
1786 | 1811 | ||
1812 | if (setup_color_cpus(sched)) | ||
1813 | return -1; | ||
1814 | |||
1787 | setup_pager(); | 1815 | setup_pager(); |
1788 | if (perf_sched__read_events(sched)) | 1816 | if (perf_sched__read_events(sched)) |
1789 | return -1; | 1817 | return -1; |
@@ -1941,6 +1969,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1941 | "map output in compact mode"), | 1969 | "map output in compact mode"), |
1942 | OPT_STRING(0, "color-pids", &sched.map.color_pids_str, "pids", | 1970 | OPT_STRING(0, "color-pids", &sched.map.color_pids_str, "pids", |
1943 | "highlight given pids in map"), | 1971 | "highlight given pids in map"), |
1972 | OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus", | ||
1973 | "highlight given CPUs in map"), | ||
1944 | OPT_END() | 1974 | OPT_END() |
1945 | }; | 1975 | }; |
1946 | const char * const latency_usage[] = { | 1976 | const char * const latency_usage[] = { |