Linux Perf
callchain.c File Reference
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <math.h>
#include "asm/bug.h"
#include "hist.h"
#include "util.h"
#include "sort.h"
#include "machine.h"
#include "callchain.h"
#include "branch.h"
Include dependency graph for callchain.c:

Go to the source code of this file.

Macros

#define CALLCHAIN_PARAM_DEFAULT
 

Enumerations

enum  match_result { MATCH_ERROR = -1, MATCH_EQ, MATCH_LT, MATCH_GT }
 

Functions

int parse_callchain_record_opt (const char *arg, struct callchain_param *param)
 
static int parse_callchain_mode (const char *value)
 
static int parse_callchain_order (const char *value)
 
static int parse_callchain_sort_key (const char *value)
 
static int parse_callchain_value (const char *value)
 
static int get_stack_size (const char *str, unsigned long *_size)
 
static int __parse_callchain_report_opt (const char *arg, bool allow_record_opt)
 
int parse_callchain_report_opt (const char *arg)
 
int parse_callchain_top_opt (const char *arg)
 
int parse_callchain_record (const char *arg, struct callchain_param *param)
 
int perf_callchain_config (const char *var, const char *value)
 
static void rb_insert_callchain (struct rb_root *root, struct callchain_node *chain, enum chain_mode mode)
 
static void __sort_chain_flat (struct rb_root *rb_root, struct callchain_node *node, u64 min_hit)
 
static void sort_chain_flat (struct rb_root *rb_root, struct callchain_root *root, u64 min_hit, struct callchain_param *param __maybe_unused)
 
static void __sort_chain_graph_abs (struct callchain_node *node, u64 min_hit)
 
static void sort_chain_graph_abs (struct rb_root *rb_root, struct callchain_root *chain_root, u64 min_hit, struct callchain_param *param __maybe_unused)
 
static void __sort_chain_graph_rel (struct callchain_node *node, double min_percent)
 
static void sort_chain_graph_rel (struct rb_root *rb_root, struct callchain_root *chain_root, u64 min_hit __maybe_unused, struct callchain_param *param)
 
int callchain_register_param (struct callchain_param *param)
 
static struct callchain_nodecreate_child (struct callchain_node *parent, bool inherit_children)
 
static int fill_node (struct callchain_node *node, struct callchain_cursor *cursor)
 
static struct callchain_nodeadd_child (struct callchain_node *parent, struct callchain_cursor *cursor, u64 period)
 
static enum match_result match_chain_strings (const char *left, const char *right)
 
static enum match_result match_chain_dso_addresses (struct map *left_map, u64 left_ip, struct map *right_map, u64 right_ip)
 
static enum match_result match_chain (struct callchain_cursor_node *node, struct callchain_list *cnode)
 
static int split_add_child (struct callchain_node *parent, struct callchain_cursor *cursor, struct callchain_list *to_split, u64 idx_parents, u64 idx_local, u64 period)
 
static enum match_result append_chain (struct callchain_node *root, struct callchain_cursor *cursor, u64 period)
 
static int append_chain_children (struct callchain_node *root, struct callchain_cursor *cursor, u64 period)
 
int callchain_append (struct callchain_root *root, struct callchain_cursor *cursor, u64 period)
 
static int merge_chain_branch (struct callchain_cursor *cursor, struct callchain_node *dst, struct callchain_node *src)
 
int callchain_merge (struct callchain_cursor *cursor, struct callchain_root *dst, struct callchain_root *src)
 
int callchain_cursor_append (struct callchain_cursor *cursor, u64 ip, struct map *map, struct symbol *sym, bool branch, struct branch_flags *flags, int nr_loop_iter, u64 iter_cycles, u64 branch_from, const char *srcline)
 
int sample__resolve_callchain (struct perf_sample *sample, struct callchain_cursor *cursor, struct symbol **parent, struct perf_evsel *evsel, struct addr_location *al, int max_stack)
 
int hist_entry__append_callchain (struct hist_entry *he, struct perf_sample *sample)
 
int fill_callchain_info (struct addr_location *al, struct callchain_cursor_node *node, bool hide_unresolved)
 
char * callchain_list__sym_name (struct callchain_list *cl, char *bf, size_t bfsize, bool show_dso)
 
char * callchain_node__scnprintf_value (struct callchain_node *node, char *bf, size_t bfsize, u64 total)
 
int callchain_node__fprintf_value (struct callchain_node *node, FILE *fp, u64 total)
 
static void callchain_counts_value (struct callchain_node *node, u64 *branch_count, u64 *predicted_count, u64 *abort_count, u64 *cycles_count)
 
static int callchain_node_branch_counts_cumul (struct callchain_node *node, u64 *branch_count, u64 *predicted_count, u64 *abort_count, u64 *cycles_count)
 
int callchain_branch_counts (struct callchain_root *root, u64 *branch_count, u64 *predicted_count, u64 *abort_count, u64 *cycles_count)
 
static int count_pri64_printf (int idx, const char *str, u64 value, char *bf, int bfsize)
 
static int count_float_printf (int idx, const char *str, float value, char *bf, int bfsize, float threshold)
 
static int branch_to_str (char *bf, int bfsize, u64 branch_count, u64 predicted_count, u64 abort_count, struct branch_type_stat *brtype_stat)
 
static int branch_from_str (char *bf, int bfsize, u64 branch_count, u64 cycles_count, u64 iter_count, u64 iter_cycles)
 
static int counts_str_build (char *bf, int bfsize, u64 branch_count, u64 predicted_count, u64 abort_count, u64 cycles_count, u64 iter_count, u64 iter_cycles, struct branch_type_stat *brtype_stat)
 
static int callchain_counts_printf (FILE *fp, char *bf, int bfsize, u64 branch_count, u64 predicted_count, u64 abort_count, u64 cycles_count, u64 iter_count, u64 iter_cycles, struct branch_type_stat *brtype_stat)
 
int callchain_list_counts__printf_value (struct callchain_list *clist, FILE *fp, char *bf, int bfsize)
 
static void free_callchain_node (struct callchain_node *node)
 
void free_callchain (struct callchain_root *root)
 
static u64 decay_callchain_node (struct callchain_node *node)
 
void decay_callchain (struct callchain_root *root)
 
int callchain_node__make_parent_list (struct callchain_node *node)
 
int callchain_cursor__copy (struct callchain_cursor *dst, struct callchain_cursor *src)
 

Variables

struct callchain_param callchain_param
 
bool dwarf_callchain_users
 
struct callchain_param callchain_param_default
 
__thread struct callchain_cursor callchain_cursor
 

Macro Definition Documentation

◆ CALLCHAIN_PARAM_DEFAULT

#define CALLCHAIN_PARAM_DEFAULT
Value:
.mode = CHAIN_GRAPH_ABS, \
.min_percent = 0.5, \
.order = ORDER_CALLEE, \
.key = CCKEY_FUNCTION, \
.value = CCVAL_PERCENT, \

Definition at line 29 of file callchain.c.

Enumeration Type Documentation

◆ match_result

Enumerator
MATCH_ERROR 
MATCH_EQ 
MATCH_LT 
MATCH_GT 

Definition at line 652 of file callchain.c.

Function Documentation

◆ __parse_callchain_report_opt()

static int __parse_callchain_report_opt ( const char *  arg,
bool  allow_record_opt 
)
static

Definition at line 161 of file callchain.c.

Here is the call graph for this function:

◆ __sort_chain_flat()

static void __sort_chain_flat ( struct rb_root *  rb_root,
struct callchain_node node,
u64  min_hit 
)
static

Definition at line 406 of file callchain.c.

Here is the call graph for this function:

◆ __sort_chain_graph_abs()

static void __sort_chain_graph_abs ( struct callchain_node node,
u64  min_hit 
)
static

Definition at line 436 of file callchain.c.

Here is the call graph for this function:

◆ __sort_chain_graph_rel()

static void __sort_chain_graph_rel ( struct callchain_node node,
double  min_percent 
)
static

Definition at line 464 of file callchain.c.

Here is the call graph for this function:

◆ add_child()

static struct callchain_node* add_child ( struct callchain_node parent,
struct callchain_cursor cursor,
u64  period 
)
static

Definition at line 623 of file callchain.c.

Here is the call graph for this function:

◆ append_chain()

static enum match_result append_chain ( struct callchain_node root,
struct callchain_cursor cursor,
u64  period 
)
static

Definition at line 906 of file callchain.c.

Here is the call graph for this function:

◆ append_chain_children()

static int append_chain_children ( struct callchain_node root,
struct callchain_cursor cursor,
u64  period 
)
static

Definition at line 859 of file callchain.c.

Here is the call graph for this function:

◆ branch_from_str()

static int branch_from_str ( char *  bf,
int  bfsize,
u64  branch_count,
u64  cycles_count,
u64  iter_count,
u64  iter_cycles 
)
static

Definition at line 1345 of file callchain.c.

Here is the call graph for this function:

◆ branch_to_str()

static int branch_to_str ( char *  bf,
int  bfsize,
u64  branch_count,
u64  predicted_count,
u64  abort_count,
struct branch_type_stat brtype_stat 
)
static

Definition at line 1316 of file callchain.c.

Here is the call graph for this function:

◆ callchain_append()

int callchain_append ( struct callchain_root root,
struct callchain_cursor cursor,
u64  period 
)

Definition at line 969 of file callchain.c.

Here is the call graph for this function:

◆ callchain_branch_counts()

int callchain_branch_counts ( struct callchain_root root,
u64 *  branch_count,
u64 *  predicted_count,
u64 *  abort_count,
u64 *  cycles_count 
)

Definition at line 1271 of file callchain.c.

Here is the call graph for this function:

◆ callchain_counts_printf()

static int callchain_counts_printf ( FILE *  fp,
char *  bf,
int  bfsize,
u64  branch_count,
u64  predicted_count,
u64  abort_count,
u64  cycles_count,
u64  iter_count,
u64  iter_cycles,
struct branch_type_stat brtype_stat 
)
static

Definition at line 1401 of file callchain.c.

Here is the call graph for this function:

◆ callchain_counts_value()

static void callchain_counts_value ( struct callchain_node node,
u64 *  branch_count,
u64 *  predicted_count,
u64 *  abort_count,
u64 *  cycles_count 
)
static

Definition at line 1223 of file callchain.c.

◆ callchain_cursor__copy()

int callchain_cursor__copy ( struct callchain_cursor dst,
struct callchain_cursor src 
)

Definition at line 1544 of file callchain.c.

Here is the call graph for this function:

◆ callchain_cursor_append()

int callchain_cursor_append ( struct callchain_cursor cursor,
u64  ip,
struct map map,
struct symbol sym,
bool  branch,
struct branch_flags flags,
int  nr_loop_iter,
u64  iter_cycles,
u64  branch_from,
const char *  srcline 
)

Definition at line 1038 of file callchain.c.

Here is the call graph for this function:

◆ callchain_list__sym_name()

char* callchain_list__sym_name ( struct callchain_list cl,
char *  bf,
size_t  bfsize,
bool  show_dso 
)

Definition at line 1139 of file callchain.c.

◆ callchain_list_counts__printf_value()

int callchain_list_counts__printf_value ( struct callchain_list clist,
FILE *  fp,
char *  bf,
int  bfsize 
)

Definition at line 1419 of file callchain.c.

Here is the call graph for this function:

◆ callchain_merge()

int callchain_merge ( struct callchain_cursor cursor,
struct callchain_root dst,
struct callchain_root src 
)

Definition at line 1032 of file callchain.c.

Here is the call graph for this function:

◆ callchain_node__fprintf_value()

int callchain_node__fprintf_value ( struct callchain_node node,
FILE *  fp,
u64  total 
)

Definition at line 1197 of file callchain.c.

Here is the call graph for this function:

◆ callchain_node__make_parent_list()

int callchain_node__make_parent_list ( struct callchain_node node)

Definition at line 1504 of file callchain.c.

Here is the call graph for this function:

◆ callchain_node__scnprintf_value()

char* callchain_node__scnprintf_value ( struct callchain_node node,
char *  bf,
size_t  bfsize,
u64  total 
)

Definition at line 1168 of file callchain.c.

Here is the call graph for this function:

◆ callchain_node_branch_counts_cumul()

static int callchain_node_branch_counts_cumul ( struct callchain_node node,
u64 *  branch_count,
u64 *  predicted_count,
u64 *  abort_count,
u64 *  cycles_count 
)
static

Definition at line 1244 of file callchain.c.

Here is the call graph for this function:

◆ callchain_register_param()

int callchain_register_param ( struct callchain_param param)

Definition at line 494 of file callchain.c.

Here is the call graph for this function:

◆ count_float_printf()

static int count_float_printf ( int  idx,
const char *  str,
float  value,
char *  bf,
int  bfsize,
float  threshold 
)
static

Definition at line 1303 of file callchain.c.

◆ count_pri64_printf()

static int count_pri64_printf ( int  idx,
const char *  str,
u64  value,
char *  bf,
int  bfsize 
)
static

Definition at line 1294 of file callchain.c.

◆ counts_str_build()

static int counts_str_build ( char *  bf,
int  bfsize,
u64  branch_count,
u64  predicted_count,
u64  abort_count,
u64  cycles_count,
u64  iter_count,
u64  iter_cycles,
struct branch_type_stat brtype_stat 
)
static

Definition at line 1376 of file callchain.c.

Here is the call graph for this function:

◆ create_child()

static struct callchain_node* create_child ( struct callchain_node parent,
bool  inherit_children 
)
static

Definition at line 519 of file callchain.c.

Here is the call graph for this function:

◆ decay_callchain()

void decay_callchain ( struct callchain_root root)

Definition at line 1496 of file callchain.c.

Here is the call graph for this function:

◆ decay_callchain_node()

static u64 decay_callchain_node ( struct callchain_node node)
static

Definition at line 1476 of file callchain.c.

◆ fill_callchain_info()

int fill_callchain_info ( struct addr_location al,
struct callchain_cursor_node node,
bool  hide_unresolved 
)

Definition at line 1099 of file callchain.c.

Here is the call graph for this function:

◆ fill_node()

static int fill_node ( struct callchain_node node,
struct callchain_cursor cursor 
)
static

Definition at line 559 of file callchain.c.

Here is the call graph for this function:

◆ free_callchain()

void free_callchain ( struct callchain_root root)

Definition at line 1468 of file callchain.c.

Here is the call graph for this function:

◆ free_callchain_node()

static void free_callchain_node ( struct callchain_node node)
static

Definition at line 1439 of file callchain.c.

Here is the call graph for this function:

◆ get_stack_size()

static int get_stack_size ( const char *  str,
unsigned long *  _size 
)
static

Definition at line 134 of file callchain.c.

◆ hist_entry__append_callchain()

int hist_entry__append_callchain ( struct hist_entry he,
struct perf_sample sample 
)

Definition at line 1091 of file callchain.c.

Here is the call graph for this function:

◆ match_chain()

static enum match_result match_chain ( struct callchain_cursor_node node,
struct callchain_list cnode 
)
static

Definition at line 703 of file callchain.c.

Here is the call graph for this function:

◆ match_chain_dso_addresses()

static enum match_result match_chain_dso_addresses ( struct map left_map,
u64  left_ip,
struct map right_map,
u64  right_ip 
)
static

Definition at line 688 of file callchain.c.

◆ match_chain_strings()

static enum match_result match_chain_strings ( const char *  left,
const char *  right 
)
static

Definition at line 659 of file callchain.c.

◆ merge_chain_branch()

static int merge_chain_branch ( struct callchain_cursor cursor,
struct callchain_node dst,
struct callchain_node src 
)
static

Definition at line 988 of file callchain.c.

Here is the call graph for this function:

◆ parse_callchain_mode()

static int parse_callchain_mode ( const char *  value)
static

Definition at line 60 of file callchain.c.

◆ parse_callchain_order()

static int parse_callchain_order ( const char *  value)
static

Definition at line 81 of file callchain.c.

◆ parse_callchain_record()

int parse_callchain_record ( const char *  arg,
struct callchain_param param 
)

Definition at line 243 of file callchain.c.

Here is the call graph for this function:

◆ parse_callchain_record_opt()

int parse_callchain_record_opt ( const char *  arg,
struct callchain_param param 
)

Definition at line 55 of file callchain.c.

Here is the call graph for this function:

◆ parse_callchain_report_opt()

int parse_callchain_report_opt ( const char *  arg)

Definition at line 233 of file callchain.c.

Here is the call graph for this function:

◆ parse_callchain_sort_key()

static int parse_callchain_sort_key ( const char *  value)
static

Definition at line 96 of file callchain.c.

◆ parse_callchain_top_opt()

int parse_callchain_top_opt ( const char *  arg)

Definition at line 238 of file callchain.c.

Here is the call graph for this function:

◆ parse_callchain_value()

static int parse_callchain_value ( const char *  value)
static

Definition at line 117 of file callchain.c.

◆ perf_callchain_config()

int perf_callchain_config ( const char *  var,
const char *  value 
)

Definition at line 306 of file callchain.c.

Here is the call graph for this function:

◆ rb_insert_callchain()

static void rb_insert_callchain ( struct rb_root *  root,
struct callchain_node chain,
enum chain_mode  mode 
)
static

Definition at line 365 of file callchain.c.

Here is the call graph for this function:

◆ sample__resolve_callchain()

int sample__resolve_callchain ( struct perf_sample sample,
struct callchain_cursor cursor,
struct symbol **  parent,
struct perf_evsel evsel,
struct addr_location al,
int  max_stack 
)

Definition at line 1075 of file callchain.c.

Here is the call graph for this function:

◆ sort_chain_flat()

static void sort_chain_flat ( struct rb_root *  rb_root,
struct callchain_root root,
u64  min_hit,
struct callchain_param *param  __maybe_unused 
)
static

Definition at line 429 of file callchain.c.

Here is the call graph for this function:

◆ sort_chain_graph_abs()

static void sort_chain_graph_abs ( struct rb_root *  rb_root,
struct callchain_root chain_root,
u64  min_hit,
struct callchain_param *param  __maybe_unused 
)
static

Definition at line 457 of file callchain.c.

Here is the call graph for this function:

◆ sort_chain_graph_rel()

static void sort_chain_graph_rel ( struct rb_root *  rb_root,
struct callchain_root chain_root,
u64 min_hit  __maybe_unused,
struct callchain_param param 
)
static

Definition at line 487 of file callchain.c.

Here is the call graph for this function:

◆ split_add_child()

static int split_add_child ( struct callchain_node parent,
struct callchain_cursor cursor,
struct callchain_list to_split,
u64  idx_parents,
u64  idx_local,
u64  period 
)
static

Definition at line 781 of file callchain.c.

Here is the call graph for this function:

Variable Documentation

◆ callchain_cursor

Definition at line 53 of file callchain.c.

◆ callchain_param

Initial value:
= {
}
#define CALLCHAIN_PARAM_DEFAULT
Definition: callchain.c:29

Definition at line 36 of file callchain.c.

◆ callchain_param_default

struct callchain_param callchain_param_default
Initial value:
= {
}
#define CALLCHAIN_PARAM_DEFAULT
Definition: callchain.c:29

Definition at line 49 of file callchain.c.

◆ dwarf_callchain_users

bool dwarf_callchain_users

Definition at line 47 of file callchain.c.