]> bbs.cooldavid.org Git - net-next-2.6.git/blob - tools/perf/util/callchain.h
Merge branch 'x86-mem-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[net-next-2.6.git] / tools / perf / util / callchain.h
1 #ifndef __PERF_CALLCHAIN_H
2 #define __PERF_CALLCHAIN_H
3
4 #include "../perf.h"
5 #include <linux/list.h>
6 #include <linux/rbtree.h>
7 #include "event.h"
8 #include "symbol.h"
9
10 enum chain_mode {
11         CHAIN_NONE,
12         CHAIN_FLAT,
13         CHAIN_GRAPH_ABS,
14         CHAIN_GRAPH_REL
15 };
16
17 struct callchain_node {
18         struct callchain_node   *parent;
19         struct list_head        brothers;
20         struct list_head        children;
21         struct list_head        val;
22         struct rb_node          rb_node; /* to sort nodes in an rbtree */
23         struct rb_root          rb_root; /* sorted tree of children */
24         unsigned int            val_nr;
25         u64                     hit;
26         u64                     children_hit;
27 };
28
29 struct callchain_root {
30         u64                     max_depth;
31         struct callchain_node   node;
32 };
33
34 struct callchain_param;
35
36 typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *,
37                                  u64, struct callchain_param *);
38
39 struct callchain_param {
40         enum chain_mode         mode;
41         u32                     print_limit;
42         double                  min_percent;
43         sort_chain_func_t       sort;
44 };
45
46 struct callchain_list {
47         u64                     ip;
48         struct map_symbol       ms;
49         struct list_head        list;
50 };
51
52 static inline void callchain_init(struct callchain_root *root)
53 {
54         INIT_LIST_HEAD(&root->node.brothers);
55         INIT_LIST_HEAD(&root->node.children);
56         INIT_LIST_HEAD(&root->node.val);
57
58         root->node.parent = NULL;
59         root->node.hit = 0;
60         root->node.children_hit = 0;
61         root->max_depth = 0;
62 }
63
64 static inline u64 cumul_hits(struct callchain_node *node)
65 {
66         return node->hit + node->children_hit;
67 }
68
69 int register_callchain_param(struct callchain_param *param);
70 int callchain_append(struct callchain_root *root, struct ip_callchain *chain,
71                      struct map_symbol *syms, u64 period);
72 int callchain_merge(struct callchain_root *dst, struct callchain_root *src);
73
74 bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event);
75 #endif  /* __PERF_CALLCHAIN_H */