summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-04-12 09:29:31 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-13 09:11:52 -0400
commit73643bb6a21c85509c7ae4c316f502c5a19cce65 (patch)
tree7b6012a5e736141efad95411a79431d02f4fd166 /tools/perf/builtin-sched.c
parentcf294f24f8c83bca6aa8e96b5cc4f78bed887f92 (diff)
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>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 7de04b297c14..afa057666c2a 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -135,6 +135,8 @@ struct perf_sched_map {
135 const char *color_pids_str; 135 const char *color_pids_str;
136 struct cpu_map *color_cpus; 136 struct cpu_map *color_cpus;
137 const char *color_cpus_str; 137 const char *color_cpus_str;
138 struct cpu_map *cpus;
139 const char *cpus_str;
138}; 140};
139 141
140struct perf_sched { 142struct perf_sched {
@@ -1469,6 +1471,9 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
1469 if (curr_thread && thread__has_color(curr_thread)) 1471 if (curr_thread && thread__has_color(curr_thread))
1470 pid_color = COLOR_PIDS; 1472 pid_color = COLOR_PIDS;
1471 1473
1474 if (sched->map.cpus && !cpu_map__has(sched->map.cpus, cpu))
1475 continue;
1476
1472 if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu)) 1477 if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu))
1473 cpu_color = COLOR_CPUS; 1478 cpu_color = COLOR_CPUS;
1474 1479
@@ -1483,6 +1488,9 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
1483 color_fprintf(stdout, color, " "); 1488 color_fprintf(stdout, color, " ");
1484 } 1489 }
1485 1490
1491 if (sched->map.cpus && !cpu_map__has(sched->map.cpus, this_cpu))
1492 goto out;
1493
1486 color_fprintf(stdout, color, " %12.6f secs ", (double)timestamp/1e9); 1494 color_fprintf(stdout, color, " %12.6f secs ", (double)timestamp/1e9);
1487 if (new_shortname) { 1495 if (new_shortname) {
1488 const char *pid_color = color; 1496 const char *pid_color = color;
@@ -1497,6 +1505,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
1497 if (sched->map.comp && new_cpu) 1505 if (sched->map.comp && new_cpu)
1498 color_fprintf(stdout, color, " (CPU %d)", this_cpu); 1506 color_fprintf(stdout, color, " (CPU %d)", this_cpu);
1499 1507
1508out:
1500 color_fprintf(stdout, color, "\n"); 1509 color_fprintf(stdout, color, "\n");
1501 1510
1502 thread__put(sched_in); 1511 thread__put(sched_in);
@@ -1756,6 +1765,8 @@ static int perf_sched__lat(struct perf_sched *sched)
1756 1765
1757static int setup_map_cpus(struct perf_sched *sched) 1766static int setup_map_cpus(struct perf_sched *sched)
1758{ 1767{
1768 struct cpu_map *map;
1769
1759 sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF); 1770 sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF);
1760 1771
1761 if (sched->map.comp) { 1772 if (sched->map.comp) {
@@ -1764,6 +1775,16 @@ static int setup_map_cpus(struct perf_sched *sched)
1764 return -1; 1775 return -1;
1765 } 1776 }
1766 1777
1778 if (!sched->map.cpus_str)
1779 return 0;
1780
1781 map = cpu_map__new(sched->map.cpus_str);
1782 if (!map) {
1783 pr_err("failed to get cpus map from %s\n", sched->map.cpus_str);
1784 return -1;
1785 }
1786
1787 sched->map.cpus = map;
1767 return 0; 1788 return 0;
1768} 1789}
1769 1790
@@ -1971,6 +1992,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
1971 "highlight given pids in map"), 1992 "highlight given pids in map"),
1972 OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus", 1993 OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus",
1973 "highlight given CPUs in map"), 1994 "highlight given CPUs in map"),
1995 OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus",
1996 "display given CPUs in map"),
1974 OPT_END() 1997 OPT_END()
1975 }; 1998 };
1976 const char * const latency_usage[] = { 1999 const char * const latency_usage[] = {