aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorKan Liang <kan.liang@intel.com>2015-08-11 06:30:49 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-12 12:20:28 -0400
commit9e207ddfa20781e56465ce9a537f0a377c9d34fb (patch)
tree8eea5617ff1c5e997a591ef8733aae16e1668aee /tools/perf
parentf9db0d0f1b2cf030083c83d3ed3a4bbae6bdc8b7 (diff)
perf report: Show call graph from reference events
Introduce --show-ref-call-graph for perf report to print reference callgraph for no callgraph event. Here is an example. perf report --show-ref-call-graph --stdio # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 5 of event 'cpu/cpu-cycles,call-graph=fp/' # Event count (approx.): 144985 # # Children Self Command Shared Object Symbol # ........ ........ ....... ................ ........................................ # 72.30% 0.00% sleep [kernel.vmlinux] [k] entry_SYSCALL_64_fastpath | ---entry_SYSCALL_64_fastpath | |--22.62%-- __GI___libc_nanosleep --77.38%-- [...] ...... # Samples: 6 of event 'cpu/instructions,call-graph=no/', show reference callgraph # Event count (approx.): 172780 # # Children Self Command Shared Object Symbol # ........ ........ ....... ................ ........................................ # 73.16% 0.00% sleep [kernel.vmlinux] [k] entry_SYSCALL_64_fastpath | ---entry_SYSCALL_64_fastpath | |--31.44%-- __GI___libc_nanosleep --68.56%-- [...] Signed-off-by: Kan Liang <kan.liang@intel.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1439289050-40510-3-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-report.txt11
-rw-r--r--tools/perf/builtin-report.c7
-rw-r--r--tools/perf/ui/browsers/hists.c9
-rw-r--r--tools/perf/util/hist.c7
-rw-r--r--tools/perf/util/symbol.h3
5 files changed, 33 insertions, 4 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 7b07d19e2d54..a18ba757a0ed 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -359,6 +359,17 @@ OPTIONS
359--full-source-path:: 359--full-source-path::
360 Show the full path for source files for srcline output. 360 Show the full path for source files for srcline output.
361 361
362--show-ref-call-graph::
363 When multiple events are sampled, it may not be needed to collect
364 callgraphs for all of them. The sample sites are usually nearby,
365 and it's enough to collect the callgraphs on a reference event.
366 So user can use "call-graph=no" event modifier to disable callgraph
367 for other events to reduce the overhead.
368 However, perf report cannot show callgraphs for the event which
369 disable the callgraph.
370 This option extends the perf report to show reference callgraphs,
371 which collected by reference event, in no callgraph event.
372
362include::callchain-overhead-calculation.txt[] 373include::callchain-overhead-calculation.txt[]
363 374
364SEE ALSO 375SEE ALSO
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f301e865001f..62b285e32aa5 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -316,6 +316,11 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
316 if (evname != NULL) 316 if (evname != NULL)
317 ret += fprintf(fp, " of event '%s'", evname); 317 ret += fprintf(fp, " of event '%s'", evname);
318 318
319 if (symbol_conf.show_ref_callgraph &&
320 strstr(evname, "call-graph=no")) {
321 ret += fprintf(fp, ", show reference callgraph");
322 }
323
319 if (rep->mem_mode) { 324 if (rep->mem_mode) {
320 ret += fprintf(fp, "\n# Total weight : %" PRIu64, nr_events); 325 ret += fprintf(fp, "\n# Total weight : %" PRIu64, nr_events);
321 ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order); 326 ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order);
@@ -740,6 +745,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
740 itrace_parse_synth_opts), 745 itrace_parse_synth_opts),
741 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, 746 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
742 "Show full source file name path for source lines"), 747 "Show full source file name path for source lines"),
748 OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph,
749 "Show callgraph from reference event"),
743 OPT_END() 750 OPT_END()
744 }; 751 };
745 struct perf_data_file file = { 752 struct perf_data_file file = {
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index f296b7348449..10c7ec041039 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1267,6 +1267,8 @@ static int hists__browser_title(struct hists *hists,
1267 const char *ev_name = perf_evsel__name(evsel); 1267 const char *ev_name = perf_evsel__name(evsel);
1268 char buf[512]; 1268 char buf[512];
1269 size_t buflen = sizeof(buf); 1269 size_t buflen = sizeof(buf);
1270 char ref[30] = " show reference callgraph, ";
1271 bool enable_ref = false;
1270 1272
1271 if (symbol_conf.filter_relative) { 1273 if (symbol_conf.filter_relative) {
1272 nr_samples = hists->stats.nr_non_filtered_samples; 1274 nr_samples = hists->stats.nr_non_filtered_samples;
@@ -1292,10 +1294,13 @@ static int hists__browser_title(struct hists *hists,
1292 } 1294 }
1293 } 1295 }
1294 1296
1297 if (symbol_conf.show_ref_callgraph &&
1298 strstr(ev_name, "call-graph=no"))
1299 enable_ref = true;
1295 nr_samples = convert_unit(nr_samples, &unit); 1300 nr_samples = convert_unit(nr_samples, &unit);
1296 printed = scnprintf(bf, size, 1301 printed = scnprintf(bf, size,
1297 "Samples: %lu%c of event '%s', Event count (approx.): %" PRIu64, 1302 "Samples: %lu%c of event '%s',%sEvent count (approx.): %" PRIu64,
1298 nr_samples, unit, ev_name, nr_events); 1303 nr_samples, unit, ev_name, enable_ref ? ref : " ", nr_events);
1299 1304
1300 1305
1301 if (hists->uid_filter_str) 1306 if (hists->uid_filter_str)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 1cd785b5b56e..08b6cd945f1e 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1141,7 +1141,12 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog)
1141 struct hist_entry *n; 1141 struct hist_entry *n;
1142 u64 min_callchain_hits; 1142 u64 min_callchain_hits;
1143 struct perf_evsel *evsel = hists_to_evsel(hists); 1143 struct perf_evsel *evsel = hists_to_evsel(hists);
1144 bool use_callchain = evsel ? (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) : symbol_conf.use_callchain; 1144 bool use_callchain;
1145
1146 if (evsel && !symbol_conf.show_ref_callgraph)
1147 use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
1148 else
1149 use_callchain = symbol_conf.use_callchain;
1145 1150
1146 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100); 1151 min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
1147 1152
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index b98ce51af142..a4cde92afbad 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -106,7 +106,8 @@ struct symbol_conf {
106 filter_relative, 106 filter_relative,
107 show_hist_headers, 107 show_hist_headers,
108 branch_callstack, 108 branch_callstack,
109 has_filter; 109 has_filter,
110 show_ref_callgraph;
110 const char *vmlinux_name, 111 const char *vmlinux_name,
111 *kallsyms_name, 112 *kallsyms_name,
112 *source_prefix, 113 *source_prefix,