blob: 1cba1f5504e71ed7747e0263072503643983b1f7 [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 Weisbecker66e274f2009-08-12 11:07:25 +02008#include "util.h"
Frederic Weisbecker44249612009-07-01 05:35:14 +02009#include "symbol.h"
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020010
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020011enum chain_mode {
Frederic Weisbeckerb1a88342009-08-08 02:16:24 +020012 CHAIN_NONE,
Frederic Weisbecker805d1272009-07-05 07:39:21 +020013 CHAIN_FLAT,
14 CHAIN_GRAPH_ABS,
15 CHAIN_GRAPH_REL
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020016};
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020017
18struct callchain_node {
19 struct callchain_node *parent;
20 struct list_head brothers;
Ingo Molnarf37a2912009-07-01 12:37:06 +020021 struct list_head children;
22 struct list_head val;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020023 struct rb_node rb_node; /* to sort nodes in an rbtree */
24 struct rb_root rb_root; /* sorted tree of children */
Ingo Molnarf37a2912009-07-01 12:37:06 +020025 unsigned int val_nr;
26 u64 hit;
Frederic Weisbecker19532872009-08-07 07:11:05 +020027 u64 children_hit;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020028};
29
Frederic Weisbecker805d1272009-07-05 07:39:21 +020030struct callchain_param;
31
32typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
33 u64, struct callchain_param *);
34
35struct callchain_param {
36 enum chain_mode mode;
Arnaldo Carvalho de Melo232a5c92010-05-09 20:28:10 -030037 u32 print_limit;
Frederic Weisbecker805d1272009-07-05 07:39:21 +020038 double min_percent;
39 sort_chain_func_t sort;
40};
41
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020042struct callchain_list {
Ingo Molnarf37a2912009-07-01 12:37:06 +020043 u64 ip;
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -030044 struct map_symbol ms;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020045 struct list_head list;
46};
47
48static 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 Weisbecker19532872009-08-07 07:11:05 +020055static inline u64 cumul_hits(struct callchain_node *node)
56{
57 return node->hit + node->children_hit;
58}
59
Frederic Weisbecker805d1272009-07-05 07:39:21 +020060int register_callchain_param(struct callchain_param *param);
Frederic Weisbecker301fde22010-03-22 13:09:33 -030061int append_chain(struct callchain_node *root, struct ip_callchain *chain,
Arnaldo Carvalho de Melob3c9ac02010-03-24 16:40:18 -030062 struct map_symbol *syms);
Arnaldo Carvalho de Melo139633c2010-05-09 11:47:13 -030063
64bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
John Kacur8b40f522009-09-24 18:02:18 +020065#endif /* __PERF_CALLCHAIN_H */