Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261467

[PATCH v4 3/4] perf callchain: Add count fields to struct callchain_node

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH v4 3/4] perf callchain: Add count fields to struct callchain_node
Date 2015-11-03 14:00 +0100
Message-ID <qqJlV-2OU-27@gated-at.bofh.it> (permalink)
References <qqJlU-2OU-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


It's to track the count of occurrences of the callchains.

Acked-by: Brendan Gregg <brendan.d.gregg@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/callchain.c | 10 ++++++++++
 tools/perf/util/callchain.h |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index e2ef9b38acb6..60754de700d4 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -437,6 +437,8 @@ add_child(struct callchain_node *parent,
 
 	new->children_hit = 0;
 	new->hit = period;
+	new->children_count = 0;
+	new->count = 1;
 	return new;
 }
 
@@ -484,6 +486,9 @@ split_add_child(struct callchain_node *parent,
 	parent->children_hit = callchain_cumul_hits(new);
 	new->val_nr = 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 */
 	if (idx_total < cursor->nr) {
@@ -494,6 +499,8 @@ split_add_child(struct callchain_node *parent,
 
 		parent->hit = 0;
 		parent->children_hit += period;
+		parent->count = 0;
+		parent->children_count += 1;
 
 		node = callchain_cursor_current(cursor);
 		new = add_child(parent, cursor, period);
@@ -516,6 +523,7 @@ split_add_child(struct callchain_node *parent,
 		rb_insert_color(&new->rb_node_in, &parent->rb_root_in);
 	} else {
 		parent->hit = period;
+		parent->count = 1;
 	}
 }
 
@@ -562,6 +570,7 @@ append_chain_children(struct callchain_node *root,
 
 inc_children_hit:
 	root->children_hit += period;
+	root->children_count++;
 }
 
 static int
@@ -614,6 +623,7 @@ append_chain(struct callchain_node *root,
 	/* we match 100% of the path, increment the hit */
 	if (matches == root->val_nr && cursor->pos == cursor->nr) {
 		root->hit += period;
+		root->count++;
 		return 0;
 	}
 
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index f9e00e3d1243..0e6cc83f1a46 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -60,6 +60,8 @@ struct callchain_node {
 	struct rb_root		rb_root_in; /* input tree of children */
 	struct rb_root		rb_root;    /* sorted output tree of children */
 	unsigned int		val_nr;
+	unsigned int		count;
+	unsigned int		children_count;
 	u64			hit;
 	u64			children_hit;
 };
@@ -145,6 +147,11 @@ static inline u64 callchain_cumul_hits(struct callchain_node *node)
 	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_append(struct callchain_root *root,
 		     struct callchain_cursor *cursor,
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHSET 0/4] perf report: Support folded callchain output (v4) Namhyung Kim <namhyung@kernel.org> - 2015-11-03 14:00 +0100
  [PATCH v4 3/4] perf callchain: Add count fields to struct callchain_node Namhyung Kim <namhyung@kernel.org> - 2015-11-03 14:00 +0100
  [PATCH v4 4/4] perf report: Add callchain value option Namhyung Kim <namhyung@kernel.org> - 2015-11-03 14:00 +0100
  [PATCH v4 2/4] perf callchain: Abstract callchain print function Namhyung Kim <namhyung@kernel.org> - 2015-11-03 14:00 +0100
  [PATCH v4 1/4] perf report: Support folded callchain mode on --stdio Namhyung Kim <namhyung@kernel.org> - 2015-11-03 14:00 +0100
  Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-03 15:50 +0100
    Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Brendan Gregg <brendan.d.gregg@gmail.com> - 2015-11-03 22:40 +0100
      Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Namhyung Kim <namhyung@kernel.org> - 2015-11-04 03:00 +0100
        Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Brendan Gregg <brendan.d.gregg@gmail.com> - 2015-11-04 07:10 +0100
          Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-11-04 16:00 +0100
            Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Namhyung Kim <namhyung@kernel.org> - 2015-11-04 16:40 +0100
              Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com> - 2015-11-04 19:10 +0100
                Re: [PATCHSET 0/4] perf report: Support folded callchain output (v4) Namhyung Kim <namhyung@kernel.org> - 2015-11-05 12:40 +0100

csiph-web