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

perf sched map: Display only given cpus

Introducing --cpus option that will display only given cpus. Could be
used together with color-cpus option.

$ perf sched map --cpus 0,1
*A0 309999.786924 secs A0 => rcu_sched:7
*. 309999.786930 secs
*B0 . 309999.786931 secs B0 => rcuos/2:25
B0 *A0 309999.786947 secs

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
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-9-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
73643bb6 cf294f24

+26
+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 + --cpus:: 61 + Show just entries with activities for the given CPUs. 62 + 60 63 --color-cpus:: 61 64 Highlight the given cpus. 62 65
+23
tools/perf/builtin-sched.c
··· 135 135 const char *color_pids_str; 136 136 struct cpu_map *color_cpus; 137 137 const char *color_cpus_str; 138 + struct cpu_map *cpus; 139 + const char *cpus_str; 138 140 }; 139 141 140 142 struct perf_sched { ··· 1471 1469 if (curr_thread && thread__has_color(curr_thread)) 1472 1470 pid_color = COLOR_PIDS; 1473 1471 1472 + if (sched->map.cpus && !cpu_map__has(sched->map.cpus, cpu)) 1473 + continue; 1474 + 1474 1475 if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu)) 1475 1476 cpu_color = COLOR_CPUS; 1476 1477 ··· 1487 1482 else 1488 1483 color_fprintf(stdout, color, " "); 1489 1484 } 1485 + 1486 + if (sched->map.cpus && !cpu_map__has(sched->map.cpus, this_cpu)) 1487 + goto out; 1490 1488 1491 1489 color_fprintf(stdout, color, " %12.6f secs ", (double)timestamp/1e9); 1492 1490 if (new_shortname) { ··· 1505 1497 if (sched->map.comp && new_cpu) 1506 1498 color_fprintf(stdout, color, " (CPU %d)", this_cpu); 1507 1499 1500 + out: 1508 1501 color_fprintf(stdout, color, "\n"); 1509 1502 1510 1503 thread__put(sched_in); ··· 1765 1756 1766 1757 static int setup_map_cpus(struct perf_sched *sched) 1767 1758 { 1759 + struct cpu_map *map; 1760 + 1768 1761 sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF); 1769 1762 1770 1763 if (sched->map.comp) { ··· 1775 1764 return -1; 1776 1765 } 1777 1766 1767 + if (!sched->map.cpus_str) 1768 + return 0; 1769 + 1770 + map = cpu_map__new(sched->map.cpus_str); 1771 + if (!map) { 1772 + pr_err("failed to get cpus map from %s\n", sched->map.cpus_str); 1773 + return -1; 1774 + } 1775 + 1776 + sched->map.cpus = map; 1778 1777 return 0; 1779 1778 } 1780 1779 ··· 1992 1971 "highlight given pids in map"), 1993 1972 OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus", 1994 1973 "highlight given CPUs in map"), 1974 + OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", 1975 + "display given CPUs in map"), 1995 1976 OPT_END() 1996 1977 }; 1997 1978 const char * const latency_usage[] = {