diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-08-22 14:05:22 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-08-22 14:43:17 -0400 |
commit | d2009c5130b627d3efccae8ed36cd43450c8486d (patch) | |
tree | 22afece12b12600d9132ab76f8fe74425548351d /tools/perf/util/callchain.h | |
parent | f4e7ac0a233a4dc9b51345546ab69c64bb43e2c1 (diff) |
perf: Keep track of the max depth of a callchain
In order to implement callchains collapsing, we need to keep
track of the maximum depth in a histogram tree of callchains.
This way we'll avoid allocating an arbitrary temporary buffer
size on callchain merge time.
Signed-off-by: Frederic Weisbecker <fweisbec@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: Paul Mackerras <paulus@samba.org>
Cc: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'tools/perf/util/callchain.h')
-rw-r--r-- | tools/perf/util/callchain.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 624a96c636fd..9b93a38e88ec 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -26,9 +26,14 @@ struct callchain_node { | |||
26 | u64 children_hit; | 26 | u64 children_hit; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | struct callchain_root { | ||
30 | u64 max_depth; | ||
31 | struct callchain_node node; | ||
32 | }; | ||
33 | |||
29 | struct callchain_param; | 34 | struct callchain_param; |
30 | 35 | ||
31 | typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *, | 36 | typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *, |
32 | u64, struct callchain_param *); | 37 | u64, struct callchain_param *); |
33 | 38 | ||
34 | struct callchain_param { | 39 | struct callchain_param { |
@@ -44,14 +49,15 @@ struct callchain_list { | |||
44 | struct list_head list; | 49 | struct list_head list; |
45 | }; | 50 | }; |
46 | 51 | ||
47 | static inline void callchain_init(struct callchain_node *node) | 52 | static inline void callchain_init(struct callchain_root *root) |
48 | { | 53 | { |
49 | INIT_LIST_HEAD(&node->brothers); | 54 | INIT_LIST_HEAD(&root->node.brothers); |
50 | INIT_LIST_HEAD(&node->children); | 55 | INIT_LIST_HEAD(&root->node.children); |
51 | INIT_LIST_HEAD(&node->val); | 56 | INIT_LIST_HEAD(&root->node.val); |
52 | 57 | ||
53 | node->parent = NULL; | 58 | root->node.parent = NULL; |
54 | node->hit = 0; | 59 | root->node.hit = 0; |
60 | root->max_depth = 0; | ||
55 | } | 61 | } |
56 | 62 | ||
57 | static inline u64 cumul_hits(struct callchain_node *node) | 63 | static inline u64 cumul_hits(struct callchain_node *node) |
@@ -60,7 +66,7 @@ static inline u64 cumul_hits(struct callchain_node *node) | |||
60 | } | 66 | } |
61 | 67 | ||
62 | int register_callchain_param(struct callchain_param *param); | 68 | int register_callchain_param(struct callchain_param *param); |
63 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, | 69 | int append_chain(struct callchain_root *root, struct ip_callchain *chain, |
64 | struct map_symbol *syms, u64 period); | 70 | struct map_symbol *syms, u64 period); |
65 | 71 | ||
66 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); | 72 | bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event); |