blob: 7812122bea1d50c2518c050b0db434ffa5b34826 [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>
Frederic Weisbecker44249612009-07-01 05:35:14 +02007#include "symbol.h"
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +02008
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +02009enum chain_mode {
Frederic Weisbecker805d1272009-07-05 07:39:21 +020010 CHAIN_FLAT,
11 CHAIN_GRAPH_ABS,
12 CHAIN_GRAPH_REL
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020013};
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020014
15struct callchain_node {
16 struct callchain_node *parent;
17 struct list_head brothers;
Ingo Molnarf37a2912009-07-01 12:37:06 +020018 struct list_head children;
19 struct list_head val;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020020 struct rb_node rb_node; /* to sort nodes in an rbtree */
21 struct rb_root rb_root; /* sorted tree of children */
Ingo Molnarf37a2912009-07-01 12:37:06 +020022 unsigned int val_nr;
23 u64 hit;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020024 u64 cumul_hit; /* hit + hits of children */
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020025};
26
Frederic Weisbecker805d1272009-07-05 07:39:21 +020027struct callchain_param;
28
29typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
30 u64, struct callchain_param *);
31
32struct callchain_param {
33 enum chain_mode mode;
34 double min_percent;
35 sort_chain_func_t sort;
36};
37
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020038struct callchain_list {
Ingo Molnarf37a2912009-07-01 12:37:06 +020039 u64 ip;
Frederic Weisbecker44249612009-07-01 05:35:14 +020040 struct symbol *sym;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020041 struct list_head list;
42};
43
44static 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 Weisbecker805d1272009-07-05 07:39:21 +020051int register_callchain_param(struct callchain_param *param);
Frederic Weisbecker44249612009-07-01 05:35:14 +020052void append_chain(struct callchain_node *root, struct ip_callchain *chain,
53 struct symbol **syms);
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020054#endif