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 "symbol.h" 8 9 enum chain_mode { 10 CHAIN_NONE, 11 CHAIN_FLAT, 12 CHAIN_GRAPH_ABS, 13 CHAIN_GRAPH_REL 14 }; 15 16 struct callchain_node { 17 struct callchain_node *parent; 18 struct list_head brothers; 19 struct list_head children; 20 struct list_head val; 21 struct rb_node rb_node; /* to sort nodes in an rbtree */ 22 struct rb_root rb_root; /* sorted tree of children */ 23 unsigned int val_nr; 24 u64 hit; 25 u64 children_hit; 26 }; 27 28 struct callchain_param; 29 30 typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *, 31 u64, struct callchain_param *); 32 33 struct callchain_param { 34 enum chain_mode mode; 35 double min_percent; 36 sort_chain_func_t sort; 37 }; 38 39 struct callchain_list { 40 u64 ip; 41 struct symbol *sym; 42 struct list_head list; 43 }; 44 45 static inline void callchain_init(struct callchain_node *node) 46 { 47 INIT_LIST_HEAD(&node->brothers); 48 INIT_LIST_HEAD(&node->children); 49 INIT_LIST_HEAD(&node->val); 50 } 51 52 static inline u64 cumul_hits(struct callchain_node *node) 53 { 54 return node->hit + node->children_hit; 55 } 56 57 int register_callchain_param(struct callchain_param *param); 58 void append_chain(struct callchain_node *root, struct ip_callchain *chain, 59 struct symbol **syms); 60 #endif 61