aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorSam Liao <phyomh@gmail.com>2011-06-07 11:49:46 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2011-06-29 18:24:30 -0400
commitd797fdc5c5c245fbb05f553e68cb95d962fbdd01 (patch)
treeaa28d98f61df71a2fba55e2b4b526c77aec8de0a /tools/perf
parentaf07ce3e77d3b24ab1d71fcc5833d41800f23b2b (diff)
perf tools: Add inverted call graph report support.
Add "caller/callee" option to support inverted butterfly report, in the inverted report (with caller option), the call graph start from the callee's ancestor. Users can use such view to catch system's performance bottleneck from a sysprof like view. Using this option with specified sort order like pid gives us high level view of call graph statistics. Also add "-G" alias for inverted call graph. Signed-off-by: Sam Liao <phyomh@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Stephane Eranian <eranian@google.com> Cc: David Ahern <dsahern@gmail.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Documentation/perf-report.txt15
-rw-r--r--tools/perf/builtin-report.c33
-rw-r--r--tools/perf/util/callchain.h6
-rw-r--r--tools/perf/util/hist.c3
-rw-r--r--tools/perf/util/session.c7
5 files changed, 53 insertions, 11 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 8ba03d6e5398..cfa8e513d0fb 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -80,15 +80,24 @@ OPTIONS
80--dump-raw-trace:: 80--dump-raw-trace::
81 Dump raw trace in ASCII. 81 Dump raw trace in ASCII.
82 82
83-g [type,min]:: 83-g [type,min,order]::
84--call-graph:: 84--call-graph::
85 Display call chains using type and min percent threshold. 85 Display call chains using type, min percent threshold and order.
86 type can be either: 86 type can be either:
87 - flat: single column, linear exposure of call chains. 87 - flat: single column, linear exposure of call chains.
88 - graph: use a graph tree, displaying absolute overhead rates. 88 - graph: use a graph tree, displaying absolute overhead rates.
89 - fractal: like graph, but displays relative rates. Each branch of 89 - fractal: like graph, but displays relative rates. Each branch of
90 the tree is considered as a new profiled object. + 90 the tree is considered as a new profiled object. +
91 Default: fractal,0.5. 91
92 order can be either:
93 - callee: callee based call graph.
94 - caller: inverted caller based call graph.
95
96 Default: fractal,0.5,callee.
97
98-G::
99--inverted::
100 alias for inverted caller based call graph.
92 101
93--pretty=<key>:: 102--pretty=<key>::
94 Pretty printing style. key: normal, raw 103 Pretty printing style. key: normal, raw
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 287a173523a7..271e252dc651 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -45,7 +45,8 @@ static struct perf_read_values show_threads_values;
45static const char default_pretty_printing_style[] = "normal"; 45static const char default_pretty_printing_style[] = "normal";
46static const char *pretty_printing_style = default_pretty_printing_style; 46static const char *pretty_printing_style = default_pretty_printing_style;
47 47
48static char callchain_default_opt[] = "fractal,0.5"; 48static char callchain_default_opt[] = "fractal,0.5,callee";
49static bool inverted_callchain;
49static symbol_filter_t annotate_init; 50static symbol_filter_t annotate_init;
50 51
51static int perf_session__add_hist_entry(struct perf_session *session, 52static int perf_session__add_hist_entry(struct perf_session *session,
@@ -386,13 +387,29 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
386 if (!tok) 387 if (!tok)
387 goto setup; 388 goto setup;
388 389
389 tok2 = strtok(NULL, ",");
390 callchain_param.min_percent = strtod(tok, &endptr); 390 callchain_param.min_percent = strtod(tok, &endptr);
391 if (tok == endptr) 391 if (tok == endptr)
392 return -1; 392 return -1;
393 393
394 if (tok2) 394 /* get the print limit */
395 tok2 = strtok(NULL, ",");
396 if (!tok2)
397 goto setup;
398
399 if (tok2[0] != 'c') {
395 callchain_param.print_limit = strtod(tok2, &endptr); 400 callchain_param.print_limit = strtod(tok2, &endptr);
401 tok2 = strtok(NULL, ",");
402 if (!tok2)
403 goto setup;
404 }
405
406 /* get the call chain order */
407 if (!strcmp(tok2, "caller"))
408 callchain_param.order = ORDER_CALLER;
409 else if (!strcmp(tok2, "callee"))
410 callchain_param.order = ORDER_CALLEE;
411 else
412 return -1;
396setup: 413setup:
397 if (callchain_register_param(&callchain_param) < 0) { 414 if (callchain_register_param(&callchain_param) < 0) {
398 fprintf(stderr, "Can't register callchain params\n"); 415 fprintf(stderr, "Can't register callchain params\n");
@@ -436,9 +453,10 @@ static const struct option options[] = {
436 "regex filter to identify parent, see: '--sort parent'"), 453 "regex filter to identify parent, see: '--sort parent'"),
437 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, 454 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
438 "Only display entries with parent-match"), 455 "Only display entries with parent-match"),
439 OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent", 456 OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent, call_order",
440 "Display callchains using output_type (graph, flat, fractal, or none) and min percent threshold. " 457 "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold and callchain order. "
441 "Default: fractal,0.5", &parse_callchain_opt, callchain_default_opt), 458 "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt),
459 OPT_BOOLEAN('G', "inverted", &inverted_callchain, "alias for inverted call graph"),
442 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", 460 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
443 "only consider symbols in these dsos"), 461 "only consider symbols in these dsos"),
444 OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", 462 OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
@@ -467,6 +485,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
467 else if (use_tui) 485 else if (use_tui)
468 use_browser = 1; 486 use_browser = 1;
469 487
488 if (inverted_callchain)
489 callchain_param.order = ORDER_CALLER;
490
470 if (strcmp(input_name, "-") != 0) 491 if (strcmp(input_name, "-") != 0)
471 setup_browser(true); 492 setup_browser(true);
472 else 493 else
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 1a79df9f739f..9b4ff16cac96 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -14,6 +14,11 @@ enum chain_mode {
14 CHAIN_GRAPH_REL 14 CHAIN_GRAPH_REL
15}; 15};
16 16
17enum chain_order {
18 ORDER_CALLER,
19 ORDER_CALLEE
20};
21
17struct callchain_node { 22struct callchain_node {
18 struct callchain_node *parent; 23 struct callchain_node *parent;
19 struct list_head siblings; 24 struct list_head siblings;
@@ -41,6 +46,7 @@ struct callchain_param {
41 u32 print_limit; 46 u32 print_limit;
42 double min_percent; 47 double min_percent;
43 sort_chain_func_t sort; 48 sort_chain_func_t sort;
49 enum chain_order order;
44}; 50};
45 51
46struct callchain_list { 52struct callchain_list {
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 627a02e03c57..dae4202fa65a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -14,7 +14,8 @@ enum hist_filter {
14 14
15struct callchain_param callchain_param = { 15struct callchain_param callchain_param = {
16 .mode = CHAIN_GRAPH_REL, 16 .mode = CHAIN_GRAPH_REL,
17 .min_percent = 0.5 17 .min_percent = 0.5,
18 .order = ORDER_CALLEE
18}; 19};
19 20
20u16 hists__col_len(struct hists *self, enum hist_column col) 21u16 hists__col_len(struct hists *self, enum hist_column col)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b723f211881c..558bcf996949 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -247,9 +247,14 @@ int perf_session__resolve_callchain(struct perf_session *self,
247 callchain_cursor_reset(&self->callchain_cursor); 247 callchain_cursor_reset(&self->callchain_cursor);
248 248
249 for (i = 0; i < chain->nr; i++) { 249 for (i = 0; i < chain->nr; i++) {
250 u64 ip = chain->ips[i]; 250 u64 ip;
251 struct addr_location al; 251 struct addr_location al;
252 252
253 if (callchain_param.order == ORDER_CALLEE)
254 ip = chain->ips[i];
255 else
256 ip = chain->ips[chain->nr - i - 1];
257
253 if (ip >= PERF_CONTEXT_MAX) { 258 if (ip >= PERF_CONTEXT_MAX) {
254 switch (ip) { 259 switch (ip) {
255 case PERF_CONTEXT_HV: 260 case PERF_CONTEXT_HV: