blob: 809850fb75fbcf4d27f92fee8c9f8ea0ae5df320 [file] [log] [blame]
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +02001#ifndef __PERF_CALLCHAIN_H
2#define __PERF_CALLCHAIN_H
3
4#include "../perf.h"
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -03005#include <linux/list.h>
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -03006#include <linux/rbtree.h>
Arnaldo Carvalho de Melo139633c2010-05-09 11:47:13 -03007#include "event.h"
Frederic Weisbecker44249612009-07-01 05:35:14 +02008#include "symbol.h"
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +02009
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020010enum chain_mode {
Frederic Weisbeckerb1a88342009-08-08 02:16:24 +020011 CHAIN_NONE,
Frederic Weisbecker805d1272009-07-05 07:39:21 +020012 CHAIN_FLAT,
13 CHAIN_GRAPH_ABS,
14 CHAIN_GRAPH_REL
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020015};
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020016
17struct callchain_node {
18 struct callchain_node *parent;
19 struct list_head brothers;
Ingo Molnarf37a2912009-07-01 12:37:06 +020020 struct list_head children;
21 struct list_head val;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020022 struct rb_node rb_node; /* to sort nodes in an rbtree */
23 struct rb_root rb_root; /* sorted tree of children */
Ingo Molnarf37a2912009-07-01 12:37:06 +020024 unsigned int val_nr;
25 u64 hit;
Frederic Weisbecker19532872009-08-07 07:11:05 +020026 u64 children_hit;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020027};
28
Frederic Weisbecker805d1272009-07-05 07:39:21 +020029struct callchain_param;
30
31typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
32 u64, struct callchain_param *);
33
34struct callchain_param {
35 enum chain_mode mode;
Arnaldo Carvalho de Melo232a5c92010-05-09 20:28:10 -030036 u32 print_limit;
Frederic Weisbecker805d1272009-07-05 07:39:21 +020037 double min_percent;
38 sort_chain_func_t sort;
39};
40
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020041struct callchain_list {
Ingo Molnarf37a2912009-07-01 12:37:06 +020042 u64 ip;
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -030043 struct map_symbol ms;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020044 struct list_head list;
45};
46
47static inline void callchain_init(struct callchain_node *node)
48{
49 INIT_LIST_HEAD(&node->brothers);
50 INIT_LIST_HEAD(&node->children);
51 INIT_LIST_HEAD(&node->val);
52}
53
Frederic Weisbecker19532872009-08-07 07:11:05 +020054static inline u64 cumul_hits(struct callchain_node *node)
55{
56 return node->hit + node->children_hit;
57}
58
Frederic Weisbecker805d1272009-07-05 07:39:21 +020059int register_callchain_param(struct callchain_param *param);
Frederic Weisbecker301fde22010-03-22 13:09:33 -030060int append_chain(struct callchain_node *root, struct ip_callchain *chain,
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -030061 struct map_symbol *syms);
Arnaldo Carvalho de Melo139633c2010-05-09 11:47:13 -030062
Arnaldo Carvalho de Melo41a37e22010-06-04 08:02:07 -030063bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event);
John Kacur8b40f522009-09-24 18:02:18 +020064#endif /* __PERF_CALLCHAIN_H */