diff options
author | Anton Blanchard <anton@samba.org> | 2011-07-04 07:57:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-07-05 04:44:44 -0400 |
commit | 5d67be97f8903d05ce53597fb5f3bc25a45e8026 (patch) | |
tree | 5ce8c2407d50570d7fee79b9c7f24e8eb89384b4 /tools/perf/builtin-report.c | |
parent | 9f8b6a6cf0ee78de87ebe1e87f54bec1c1741ef7 (diff) |
perf report/annotate/script: Add option to specify a CPU range
Add an option to perf report/annotate/script to specify which
CPUs to operate on. This enables us to take a single system wide
profile and analyse each CPU (or group of CPUs) in isolation.
This was useful when profiling a multiprocess workload where the
bottleneck was on one CPU but this was hidden in the overall
profile. Per process and per thread breakdowns didn't help
because multiple processes were running on each CPU and no
single process consumed an entire CPU.
The patch converts the list of CPUs returned by cpu_map__new
into a bitmap for fast lookup. I wanted to use -C to be
consistent with perf top/record/stat, but unfortunately perf
report already uses -C <comms>.
v2: Incorporate suggestions from David Ahern:
- Added -c to perf script
- Check that SAMPLE_CPU is set when -c is used
- Update documentation
v3: Create perf_session__cpu_bitmap()
Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Link: http://lkml.kernel.org/r/20110704215750.11647eb9@kryten
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 5d43d0181d63..f854efda7686 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include "util/sort.h" | 33 | #include "util/sort.h" |
34 | #include "util/hist.h" | 34 | #include "util/hist.h" |
35 | 35 | ||
36 | #include <linux/bitmap.h> | ||
37 | |||
36 | static char const *input_name = "perf.data"; | 38 | static char const *input_name = "perf.data"; |
37 | 39 | ||
38 | static bool force, use_tui, use_stdio; | 40 | static bool force, use_tui, use_stdio; |
@@ -49,6 +51,9 @@ static char callchain_default_opt[] = "fractal,0.5,callee"; | |||
49 | static bool inverted_callchain; | 51 | static bool inverted_callchain; |
50 | static symbol_filter_t annotate_init; | 52 | static symbol_filter_t annotate_init; |
51 | 53 | ||
54 | static const char *cpu_list; | ||
55 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | ||
56 | |||
52 | static int perf_session__add_hist_entry(struct perf_session *session, | 57 | static int perf_session__add_hist_entry(struct perf_session *session, |
53 | struct addr_location *al, | 58 | struct addr_location *al, |
54 | struct perf_sample *sample, | 59 | struct perf_sample *sample, |
@@ -117,6 +122,9 @@ static int process_sample_event(union perf_event *event, | |||
117 | if (al.filtered || (hide_unresolved && al.sym == NULL)) | 122 | if (al.filtered || (hide_unresolved && al.sym == NULL)) |
118 | return 0; | 123 | return 0; |
119 | 124 | ||
125 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) | ||
126 | return 0; | ||
127 | |||
120 | if (al.map != NULL) | 128 | if (al.map != NULL) |
121 | al.map->dso->hit = 1; | 129 | al.map->dso->hit = 1; |
122 | 130 | ||
@@ -263,6 +271,12 @@ static int __cmd_report(void) | |||
263 | if (session == NULL) | 271 | if (session == NULL) |
264 | return -ENOMEM; | 272 | return -ENOMEM; |
265 | 273 | ||
274 | if (cpu_list) { | ||
275 | ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); | ||
276 | if (ret) | ||
277 | goto out_delete; | ||
278 | } | ||
279 | |||
266 | if (show_threads) | 280 | if (show_threads) |
267 | perf_read_values_init(&show_threads_values); | 281 | perf_read_values_init(&show_threads_values); |
268 | 282 | ||
@@ -473,6 +487,7 @@ static const struct option options[] = { | |||
473 | "Only display entries resolved to a symbol"), | 487 | "Only display entries resolved to a symbol"), |
474 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", | 488 | OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", |
475 | "Look for files with symbols relative to this directory"), | 489 | "Look for files with symbols relative to this directory"), |
490 | OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"), | ||
476 | OPT_END() | 491 | OPT_END() |
477 | }; | 492 | }; |
478 | 493 | ||