Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 1 | #ifndef __PERF_CALLCHAIN_H |
| 2 | #define __PERF_CALLCHAIN_H |
| 3 | |
| 4 | #include "../perf.h" |
Arnaldo Carvalho de Melo | 5da5025 | 2009-07-01 14:46:08 -0300 | [diff] [blame] | 5 | #include <linux/list.h> |
Arnaldo Carvalho de Melo | 43cbcd8 | 2009-07-01 12:28:37 -0300 | [diff] [blame] | 6 | #include <linux/rbtree.h> |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 7 | #include "symbol.h" |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 8 | |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 9 | enum chain_mode { |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 10 | CHAIN_FLAT, |
| 11 | CHAIN_GRAPH_ABS, |
| 12 | CHAIN_GRAPH_REL |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 13 | }; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 14 | |
| 15 | struct callchain_node { |
| 16 | struct callchain_node *parent; |
| 17 | struct list_head brothers; |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 18 | struct list_head children; |
| 19 | struct list_head val; |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 20 | struct rb_node rb_node; /* to sort nodes in an rbtree */ |
| 21 | struct rb_root rb_root; /* sorted tree of children */ |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 22 | unsigned int val_nr; |
| 23 | u64 hit; |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 24 | u64 children_hit; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 25 | }; |
| 26 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 27 | struct callchain_param; |
| 28 | |
| 29 | typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *, |
| 30 | u64, struct callchain_param *); |
| 31 | |
| 32 | struct callchain_param { |
| 33 | enum chain_mode mode; |
| 34 | double min_percent; |
| 35 | sort_chain_func_t sort; |
| 36 | }; |
| 37 | |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 38 | struct callchain_list { |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 39 | u64 ip; |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 40 | struct symbol *sym; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 41 | struct list_head list; |
| 42 | }; |
| 43 | |
| 44 | static inline void callchain_init(struct callchain_node *node) |
| 45 | { |
| 46 | INIT_LIST_HEAD(&node->brothers); |
| 47 | INIT_LIST_HEAD(&node->children); |
| 48 | INIT_LIST_HEAD(&node->val); |
| 49 | } |
| 50 | |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 51 | static inline u64 cumul_hits(struct callchain_node *node) |
| 52 | { |
| 53 | return node->hit + node->children_hit; |
| 54 | } |
| 55 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 56 | int register_callchain_param(struct callchain_param *param); |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 57 | void append_chain(struct callchain_node *root, struct ip_callchain *chain, |
| 58 | struct symbol **syms); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 59 | #endif |