aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/callchain.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-07-05 01:39:21 -0400
committerIngo Molnar <mingo@elte.hu>2009-07-05 04:30:23 -0400
commit805d127d62472f17c7d79baa001a7651afe2fa47 (patch)
tree59dfdd2337190e168a007ba65cc25c7e5d8c0fda /tools/perf/util/callchain.c
parente05b876c222178bc6abcfa9f23d8311731691046 (diff)
perf report: Add "Fractal" mode output - support callchains with relative overhead rate
The current callchain displays the overhead rates as absolute: relative to the total overhead. This patch provides relative overhead percentage, in which each branch of the callchain tree is a independant instrumentated object. This provides a 'fractal' view of the call-chain profile: each sub-graph looks like a profile in itself - relative to its parent. You can produce such output by using the "fractal" mode that you can abbreviate via f, fr, fra, frac, etc... ./perf report -s sym -c fractal Example: 8.46% [k] copy_user_generic_string | |--52.01%-- generic_file_aio_read | do_sync_read | vfs_read | | | |--97.20%-- sys_pread64 | | system_call_fastpath | | pread64 | | | --2.81%-- sys_read | system_call_fastpath | __read | |--39.85%-- generic_file_buffered_write | __generic_file_aio_write_nolock | generic_file_aio_write | do_sync_write | reiserfs_file_write | vfs_write | | | |--97.05%-- sys_pwrite64 | | system_call_fastpath | | __pwrite64 | | | --2.95%-- sys_write | system_call_fastpath | __write_nocancel [...] Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Anton Blanchard <anton@samba.org> Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <1246772361-9960-5-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/callchain.c')
-rw-r--r--tools/perf/util/callchain.c84
1 files changed, 69 insertions, 15 deletions
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 5d244afb7cdf..9d3c8141b8c1 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -32,13 +32,14 @@ rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
32 rnode = rb_entry(parent, struct callchain_node, rb_node); 32 rnode = rb_entry(parent, struct callchain_node, rb_node);
33 33
34 switch (mode) { 34 switch (mode) {
35 case FLAT: 35 case CHAIN_FLAT:
36 if (rnode->hit < chain->hit) 36 if (rnode->hit < chain->hit)
37 p = &(*p)->rb_left; 37 p = &(*p)->rb_left;
38 else 38 else
39 p = &(*p)->rb_right; 39 p = &(*p)->rb_right;
40 break; 40 break;
41 case GRAPH: 41 case CHAIN_GRAPH_ABS: /* Falldown */
42 case CHAIN_GRAPH_REL:
42 if (rnode->cumul_hit < chain->cumul_hit) 43 if (rnode->cumul_hit < chain->cumul_hit)
43 p = &(*p)->rb_left; 44 p = &(*p)->rb_left;
44 else 45 else
@@ -53,43 +54,96 @@ rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
53 rb_insert_color(&chain->rb_node, root); 54 rb_insert_color(&chain->rb_node, root);
54} 55}
55 56
57static void
58__sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
59 u64 min_hit)
60{
61 struct callchain_node *child;
62
63 chain_for_each_child(child, node)
64 __sort_chain_flat(rb_root, child, min_hit);
65
66 if (node->hit && node->hit >= min_hit)
67 rb_insert_callchain(rb_root, node, CHAIN_FLAT);
68}
69
56/* 70/*
57 * Once we get every callchains from the stream, we can now 71 * Once we get every callchains from the stream, we can now
58 * sort them by hit 72 * sort them by hit
59 */ 73 */
60void sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node, 74static void
61 u64 min_hit) 75sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
76 u64 min_hit, struct callchain_param *param __used)
77{
78 __sort_chain_flat(rb_root, node, min_hit);
79}
80
81static void __sort_chain_graph_abs(struct callchain_node *node,
82 u64 min_hit)
62{ 83{
63 struct callchain_node *child; 84 struct callchain_node *child;
64 85
65 chain_for_each_child(child, node) 86 node->rb_root = RB_ROOT;
66 sort_chain_flat(rb_root, child, min_hit);
67 87
68 if (node->hit && node->hit >= min_hit) 88 chain_for_each_child(child, node) {
69 rb_insert_callchain(rb_root, node, FLAT); 89 __sort_chain_graph_abs(child, min_hit);
90 if (child->cumul_hit >= min_hit)
91 rb_insert_callchain(&node->rb_root, child,
92 CHAIN_GRAPH_ABS);
93 }
94}
95
96static void
97sort_chain_graph_abs(struct rb_root *rb_root, struct callchain_node *chain_root,
98 u64 min_hit, struct callchain_param *param __used)
99{
100 __sort_chain_graph_abs(chain_root, min_hit);
101 rb_root->rb_node = chain_root->rb_root.rb_node;
70} 102}
71 103
72static void __sort_chain_graph(struct callchain_node *node, u64 min_hit) 104static void __sort_chain_graph_rel(struct callchain_node *node,
105 double min_percent)
73{ 106{
74 struct callchain_node *child; 107 struct callchain_node *child;
108 u64 min_hit;
75 109
76 node->rb_root = RB_ROOT; 110 node->rb_root = RB_ROOT;
111 min_hit = node->cumul_hit * min_percent / 100.0;
77 112
78 chain_for_each_child(child, node) { 113 chain_for_each_child(child, node) {
79 __sort_chain_graph(child, min_hit); 114 __sort_chain_graph_rel(child, min_percent);
80 if (child->cumul_hit >= min_hit) 115 if (child->cumul_hit >= min_hit)
81 rb_insert_callchain(&node->rb_root, child, GRAPH); 116 rb_insert_callchain(&node->rb_root, child,
117 CHAIN_GRAPH_REL);
82 } 118 }
83} 119}
84 120
85void 121static void
86sort_chain_graph(struct rb_root *rb_root, struct callchain_node *chain_root, 122sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root,
87 u64 min_hit) 123 u64 min_hit __used, struct callchain_param *param)
88{ 124{
89 __sort_chain_graph(chain_root, min_hit); 125 __sort_chain_graph_rel(chain_root, param->min_percent);
90 rb_root->rb_node = chain_root->rb_root.rb_node; 126 rb_root->rb_node = chain_root->rb_root.rb_node;
91} 127}
92 128
129int register_callchain_param(struct callchain_param *param)
130{
131 switch (param->mode) {
132 case CHAIN_GRAPH_ABS:
133 param->sort = sort_chain_graph_abs;
134 break;
135 case CHAIN_GRAPH_REL:
136 param->sort = sort_chain_graph_rel;
137 break;
138 case CHAIN_FLAT:
139 param->sort = sort_chain_flat;
140 break;
141 default:
142 return -1;
143 }
144 return 0;
145}
146
93/* 147/*
94 * Create a child for a parent. If inherit_children, then the new child 148 * Create a child for a parent. If inherit_children, then the new child
95 * will become the new parent of it's parent children 149 * will become the new parent of it's parent children