Commit 5e47f8ff authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf callchain: Add count fields to struct callchain_node

It's to track the count of occurrences of the callchains.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1447047946-1691-5-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5ab250ca
...@@ -437,6 +437,8 @@ add_child(struct callchain_node *parent, ...@@ -437,6 +437,8 @@ add_child(struct callchain_node *parent,
new->children_hit = 0; new->children_hit = 0;
new->hit = period; new->hit = period;
new->children_count = 0;
new->count = 1;
return new; return new;
} }
...@@ -484,6 +486,9 @@ split_add_child(struct callchain_node *parent, ...@@ -484,6 +486,9 @@ split_add_child(struct callchain_node *parent,
parent->children_hit = callchain_cumul_hits(new); parent->children_hit = callchain_cumul_hits(new);
new->val_nr = parent->val_nr - idx_local; new->val_nr = parent->val_nr - idx_local;
parent->val_nr = idx_local; parent->val_nr = idx_local;
new->count = parent->count;
new->children_count = parent->children_count;
parent->children_count = callchain_cumul_counts(new);
/* create a new child for the new branch if any */ /* create a new child for the new branch if any */
if (idx_total < cursor->nr) { if (idx_total < cursor->nr) {
...@@ -494,6 +499,8 @@ split_add_child(struct callchain_node *parent, ...@@ -494,6 +499,8 @@ split_add_child(struct callchain_node *parent,
parent->hit = 0; parent->hit = 0;
parent->children_hit += period; parent->children_hit += period;
parent->count = 0;
parent->children_count += 1;
node = callchain_cursor_current(cursor); node = callchain_cursor_current(cursor);
new = add_child(parent, cursor, period); new = add_child(parent, cursor, period);
...@@ -516,6 +523,7 @@ split_add_child(struct callchain_node *parent, ...@@ -516,6 +523,7 @@ split_add_child(struct callchain_node *parent,
rb_insert_color(&new->rb_node_in, &parent->rb_root_in); rb_insert_color(&new->rb_node_in, &parent->rb_root_in);
} else { } else {
parent->hit = period; parent->hit = period;
parent->count = 1;
} }
} }
...@@ -562,6 +570,7 @@ append_chain_children(struct callchain_node *root, ...@@ -562,6 +570,7 @@ append_chain_children(struct callchain_node *root,
inc_children_hit: inc_children_hit:
root->children_hit += period; root->children_hit += period;
root->children_count++;
} }
static int static int
...@@ -614,6 +623,7 @@ append_chain(struct callchain_node *root, ...@@ -614,6 +623,7 @@ append_chain(struct callchain_node *root,
/* we match 100% of the path, increment the hit */ /* we match 100% of the path, increment the hit */
if (matches == root->val_nr && cursor->pos == cursor->nr) { if (matches == root->val_nr && cursor->pos == cursor->nr) {
root->hit += period; root->hit += period;
root->count++;
return 0; return 0;
} }
......
...@@ -60,6 +60,8 @@ struct callchain_node { ...@@ -60,6 +60,8 @@ struct callchain_node {
struct rb_root rb_root_in; /* input tree of children */ struct rb_root rb_root_in; /* input tree of children */
struct rb_root rb_root; /* sorted output tree of children */ struct rb_root rb_root; /* sorted output tree of children */
unsigned int val_nr; unsigned int val_nr;
unsigned int count;
unsigned int children_count;
u64 hit; u64 hit;
u64 children_hit; u64 children_hit;
}; };
...@@ -145,6 +147,11 @@ static inline u64 callchain_cumul_hits(struct callchain_node *node) ...@@ -145,6 +147,11 @@ static inline u64 callchain_cumul_hits(struct callchain_node *node)
return node->hit + node->children_hit; return node->hit + node->children_hit;
} }
static inline unsigned callchain_cumul_counts(struct callchain_node *node)
{
return node->count + node->children_count;
}
int callchain_register_param(struct callchain_param *param); int callchain_register_param(struct callchain_param *param);
int callchain_append(struct callchain_root *root, int callchain_append(struct callchain_root *root,
struct callchain_cursor *cursor, struct callchain_cursor *cursor,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment