1 #ifndef __PERF_CALLCHAIN_H
2 #define __PERF_CALLCHAIN_H
5 #include <linux/list.h>
6 #include <linux/rbtree.h>
17 struct callchain_node
{
18 struct callchain_node
*parent
;
19 struct list_head brothers
;
20 struct list_head children
;
22 struct rb_node rb_node
; /* to sort nodes in an rbtree */
23 struct rb_root rb_root
; /* sorted tree of children */
29 struct callchain_root
{
31 struct callchain_node node
;
34 struct callchain_param
;
36 typedef void (*sort_chain_func_t
)(struct rb_root
*, struct callchain_root
*,
37 u64
, struct callchain_param
*);
39 struct callchain_param
{
43 sort_chain_func_t sort
;
46 struct callchain_list
{
49 struct list_head list
;
52 static inline void callchain_init(struct callchain_root
*root
)
54 INIT_LIST_HEAD(&root
->node
.brothers
);
55 INIT_LIST_HEAD(&root
->node
.children
);
56 INIT_LIST_HEAD(&root
->node
.val
);
58 root
->node
.parent
= NULL
;
60 root
->node
.children_hit
= 0;
64 static inline u64
cumul_hits(struct callchain_node
*node
)
66 return node
->hit
+ node
->children_hit
;
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
);
74 bool ip_callchain__valid(struct ip_callchain
*chain
, const event_t
*event
);
75 #endif /* __PERF_CALLCHAIN_H */