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> |
Arnaldo Carvalho de Melo | 139633c | 2010-05-09 11:47:13 -0300 | [diff] [blame] | 7 | #include "event.h" |
Frederic Weisbecker | 66e274f | 2009-08-12 11:07:25 +0200 | [diff] [blame] | 8 | #include "util.h" |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 9 | #include "symbol.h" |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 10 | |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 11 | enum chain_mode { |
Frederic Weisbecker | b1a8834 | 2009-08-08 02:16:24 +0200 | [diff] [blame] | 12 | CHAIN_NONE, |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 13 | CHAIN_FLAT, |
| 14 | CHAIN_GRAPH_ABS, |
| 15 | CHAIN_GRAPH_REL |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 16 | }; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 17 | |
| 18 | struct callchain_node { |
| 19 | struct callchain_node *parent; |
| 20 | struct list_head brothers; |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 21 | struct list_head children; |
| 22 | struct list_head val; |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 23 | struct rb_node rb_node; /* to sort nodes in an rbtree */ |
| 24 | struct rb_root rb_root; /* sorted tree of children */ |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 25 | unsigned int val_nr; |
| 26 | u64 hit; |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame] | 27 | u64 children_hit; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 28 | }; |
| 29 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 30 | struct callchain_param; |
| 31 | |
| 32 | typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *, |
| 33 | u64, struct callchain_param *); |
| 34 | |
| 35 | struct callchain_param { |
| 36 | enum chain_mode mode; |
Arnaldo Carvalho de Melo | 232a5c9 | 2010-05-09 20:28:10 -0300 | [diff] [blame^] | 37 | u32 print_limit; |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 38 | double min_percent; |
| 39 | sort_chain_func_t sort; |
| 40 | }; |
| 41 | |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 42 | struct callchain_list { |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 43 | u64 ip; |
Arnaldo Carvalho de Melo | b3c9ac0 | 2010-03-24 16:40:18 -0300 | [diff] [blame] | 44 | struct map_symbol ms; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 45 | struct list_head list; |
| 46 | }; |
| 47 | |
| 48 | static inline void callchain_init(struct callchain_node *node) |
| 49 | { |
| 50 | INIT_LIST_HEAD(&node->brothers); |
| 51 | INIT_LIST_HEAD(&node->children); |
| 52 | INIT_LIST_HEAD(&node->val); |
| 53 | } |
| 54 | |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame] | 55 | static inline u64 cumul_hits(struct callchain_node *node) |
| 56 | { |
| 57 | return node->hit + node->children_hit; |
| 58 | } |
| 59 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 60 | int register_callchain_param(struct callchain_param *param); |
Frederic Weisbecker | 301fde2 | 2010-03-22 13:09:33 -0300 | [diff] [blame] | 61 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, |
Arnaldo Carvalho de Melo | b3c9ac0 | 2010-03-24 16:40:18 -0300 | [diff] [blame] | 62 | struct map_symbol *syms); |
Arnaldo Carvalho de Melo | 139633c | 2010-05-09 11:47:13 -0300 | [diff] [blame] | 63 | |
| 64 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 65 | #endif /* __PERF_CALLCHAIN_H */ |