console: move for_each_console to linux/console.h
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / tools / perf / util / callchain.h
blobc15fb8c24ad2b87388e97cd6346cfdebaac11dd5
1 #ifndef __PERF_CALLCHAIN_H
2 #define __PERF_CALLCHAIN_H
4 #include "../perf.h"
5 #include <linux/list.h>
6 #include <linux/rbtree.h>
7 #include "event.h"
8 #include "symbol.h"
10 enum chain_mode {
11 CHAIN_NONE,
12 CHAIN_FLAT,
13 CHAIN_GRAPH_ABS,
14 CHAIN_GRAPH_REL
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;
29 struct callchain_root {
30 u64 max_depth;
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 {
40 enum chain_mode mode;
41 u32 print_limit;
42 double min_percent;
43 sort_chain_func_t sort;
46 struct callchain_list {
47 u64 ip;
48 struct map_symbol ms;
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;
59 root->node.hit = 0;
60 root->node.children_hit = 0;
61 root->max_depth = 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 */