Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
cf294f24 a151a37a

+36 -3
+3
tools/perf/Documentation/perf-sched.txt
··· 57 57 Show only CPUs with activity. Helps visualizing on high core 58 58 count systems. 59 59 60 + --color-cpus:: 61 + Highlight the given cpus. 62 + 60 63 --color-pids:: 61 64 Highlight the given pids. 62 65
+33 -3
tools/perf/builtin-sched.c
··· 125 125 }; 126 126 127 127 #define COLOR_PIDS PERF_COLOR_BLUE 128 + #define COLOR_CPUS PERF_COLOR_BG_RED 128 129 129 130 struct perf_sched_map { 130 131 DECLARE_BITMAP(comp_cpus_mask, MAX_CPUS); ··· 133 132 bool comp; 134 133 struct thread_map *color_pids; 135 134 const char *color_pids_str; 135 + struct cpu_map *color_cpus; 136 + const char *color_cpus_str; 136 137 }; 137 138 138 139 struct perf_sched { ··· 1464 1461 int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i; 1465 1462 struct thread *curr_thread = sched->curr_thread[cpu]; 1466 1463 const char *pid_color = color; 1464 + const char *cpu_color = color; 1467 1465 1468 1466 if (curr_thread && thread__has_color(curr_thread)) 1469 1467 pid_color = COLOR_PIDS; 1470 1468 1469 + if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu)) 1470 + cpu_color = COLOR_CPUS; 1471 + 1471 1472 if (cpu != this_cpu) 1472 - color_fprintf(stdout, color, " "); 1473 + color_fprintf(stdout, cpu_color, " "); 1473 1474 else 1474 - color_fprintf(stdout, color, "*"); 1475 + color_fprintf(stdout, cpu_color, "*"); 1475 1476 1476 1477 if (sched->curr_thread[cpu]) 1477 1478 color_fprintf(stdout, pid_color, "%2s ", sched->curr_thread[cpu]->shortname); ··· 1760 1753 1761 1754 if (sched->map.comp) { 1762 1755 sched->map.comp_cpus = zalloc(sched->max_cpu * sizeof(int)); 1763 - return sched->map.comp_cpus ? 0 : -1; 1756 + if (!sched->map.comp_cpus) 1757 + return -1; 1764 1758 } 1765 1759 1766 1760 return 0; ··· 1784 1776 return 0; 1785 1777 } 1786 1778 1779 + static int setup_color_cpus(struct perf_sched *sched) 1780 + { 1781 + struct cpu_map *map; 1782 + 1783 + if (!sched->map.color_cpus_str) 1784 + return 0; 1785 + 1786 + map = cpu_map__new(sched->map.color_cpus_str); 1787 + if (!map) { 1788 + pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str); 1789 + return -1; 1790 + } 1791 + 1792 + sched->map.color_cpus = map; 1793 + return 0; 1794 + } 1795 + 1787 1796 static int perf_sched__map(struct perf_sched *sched) 1788 1797 { 1789 1798 if (setup_map_cpus(sched)) 1790 1799 return -1; 1791 1800 1792 1801 if (setup_color_pids(sched)) 1802 + return -1; 1803 + 1804 + if (setup_color_cpus(sched)) 1793 1805 return -1; 1794 1806 1795 1807 setup_pager(); ··· 1969 1941 "map output in compact mode"), 1970 1942 OPT_STRING(0, "color-pids", &sched.map.color_pids_str, "pids", 1971 1943 "highlight given pids in map"), 1944 + OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus", 1945 + "highlight given CPUs in map"), 1972 1946 OPT_END() 1973 1947 }; 1974 1948 const char * const latency_usage[] = {