public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Frederic Weisbecker <fweisbec@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, anton@samba.org,
	paulus@samba.org, hpa@zytor.com, mingo@redhat.com,
	a.p.zijlstra@chello.nl, efault@gmx.de, jens.axboe@oracle.com,
	fweisbec@gmail.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perfcounters/urgent] perf_counter tools: callchains: Manage the cumul hits on the fly
Date: Sun, 5 Jul 2009 09:52:28 GMT	[thread overview]
Message-ID: <tip-e05b876c222178bc6abcfa9f23d8311731691046@git.kernel.org> (raw)
In-Reply-To: <1246772361-9960-4-git-send-email-fweisbec@gmail.com>

Commit-ID:  e05b876c222178bc6abcfa9f23d8311731691046
Gitweb:     http://git.kernel.org/tip/e05b876c222178bc6abcfa9f23d8311731691046
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Sun, 5 Jul 2009 07:39:20 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 5 Jul 2009 10:30:22 +0200

perf_counter tools: callchains: Manage the cumul hits on the fly

The cumul hits are the number of hits of every childs of a node
plus the hits of the current nodes, required for percentage
computing of a branch.

Theses numbers are calculated during the sorting of the branches of
the callchain tree using a depth first postfix traversal, so that
cumulative hits are propagated in the right order.

But if we plan to implement percentages relative to the parent and not
absolute percentages (relative to the whole overhead), we need to know
the cumulative hits of the parent before computing the children
because the relative minimum acceptable number of entries (ie: minimum
rate against the cumulative hits from the parent) is the basis to
filter the children against a given rate.

Then we need to handle the cumul hits on the fly to prepare the
implementation of relative overhead rates.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anton Blanchard <anton@samba.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <1246772361-9960-4-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 tools/perf/util/callchain.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index c9900fe..5d244af 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -74,13 +74,11 @@ static void __sort_chain_graph(struct callchain_node *node, u64 min_hit)
 	struct callchain_node *child;
 
 	node->rb_root = RB_ROOT;
-	node->cumul_hit = node->hit;
 
 	chain_for_each_child(child, node) {
 		__sort_chain_graph(child, min_hit);
 		if (child->cumul_hit >= min_hit)
 			rb_insert_callchain(&node->rb_root, child, GRAPH);
-		node->cumul_hit += child->cumul_hit;
 	}
 }
 
@@ -159,7 +157,7 @@ add_child(struct callchain_node *parent, struct ip_callchain *chain,
 	new = create_child(parent, false);
 	fill_node(new, chain, start, syms);
 
-	new->hit = 1;
+	new->cumul_hit = new->hit = 1;
 }
 
 /*
@@ -189,6 +187,7 @@ split_add_child(struct callchain_node *parent, struct ip_callchain *chain,
 
 	/* split the hits */
 	new->hit = parent->hit;
+	new->cumul_hit = parent->cumul_hit;
 	new->val_nr = parent->val_nr - idx_local;
 	parent->val_nr = idx_local;
 
@@ -216,10 +215,13 @@ __append_chain_children(struct callchain_node *root, struct ip_callchain *chain,
 		unsigned int ret = __append_chain(rnode, chain, start, syms);
 
 		if (!ret)
-			return;
+			goto cumul;
 	}
 	/* nothing in children, add to the current node */
 	add_child(root, chain, start, syms);
+
+cumul:
+	root->cumul_hit++;
 }
 
 static int
@@ -261,6 +263,8 @@ __append_chain(struct callchain_node *root, struct ip_callchain *chain,
 	/* we match 100% of the path, increment the hit */
 	if (i - start == root->val_nr && i == chain->nr) {
 		root->hit++;
+		root->cumul_hit++;
+
 		return 0;
 	}
 

  reply	other threads:[~2009-07-05  9:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-05  5:39 [PATCH 1/5] perf report: Warn on callchain output request from non-callchain file Frederic Weisbecker
2009-07-05  5:39 ` [PATCH 2/5] perf report: Use a modifiable string for default callchain options Frederic Weisbecker
2009-07-05  9:52   ` [tip:perfcounters/urgent] " tip-bot for Frederic Weisbecker
2009-07-05  5:39 ` [PATCH 3/5] perf report: Change default callchain parameters Frederic Weisbecker
2009-07-05  9:52   ` [tip:perfcounters/urgent] " tip-bot for Frederic Weisbecker
2009-07-05  5:39 ` [PATCH 4/5] perf tools: callchains: Manage the cumul hits on the fly Frederic Weisbecker
2009-07-05  9:52   ` tip-bot for Frederic Weisbecker [this message]
2009-07-05  5:39 ` [PATCH 5/5] perf report: Support callchains with relative overhead rate Frederic Weisbecker
2009-07-05  8:34   ` Ingo Molnar
2009-07-05  8:59     ` Ingo Molnar
2009-07-05 13:23       ` Frederic Weisbecker
2009-07-05 13:19     ` Frederic Weisbecker
2009-07-05  9:52   ` [tip:perfcounters/urgent] perf report: Add "Fractal" mode output - support " tip-bot for Frederic Weisbecker
2009-07-05  9:51 ` [tip:perfcounters/urgent] perf report: Warn on callchain output request from non-callchain file tip-bot for Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-e05b876c222178bc6abcfa9f23d8311731691046@git.kernel.org \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=anton@samba.org \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox