From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Arun Sharma <asharma@fb.com>, David Ahern <dsahern@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung.kim@lge.com>
Subject: [PATCH 10/15] perf hists: Accumulate hist entry stat based on the callchain
Date: Thu, 13 Sep 2012 16:20:06 +0900 [thread overview]
Message-ID: <1347520811-28150-11-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1347520811-28150-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
Call add_hist_entry() for each callchain node to get an accumulated
stat for an entry. However skip nodes which do not have symbol info
as they caused subtle problems.
AFAICS the current sort methods cannot distinguish entries with NULL
dso/sym well so that processing a callchian for an entry that doesn't
have symbol info might add a period to a same entry multiple times.
It ended up with an entry that have more than 100% of accumulated
period value which is not good.
Cc: Arun Sharma <asharma@fb.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/hist.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index f96298f59e49..2b629f460889 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -387,6 +387,61 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
return __add_hist_entry(hists, &entry, al, period, sample_self);
}
+static struct hist_entry *cumulate_hist_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent,
+ u64 period)
+{
+ unsigned int i;
+ struct hist_entry *he, *he_self;
+ struct callchain_cursor cursor;
+ struct addr_location al_child;
+
+ /*
+ * make a copy of callchain cursor since callchain_cursor_next()
+ * can leak callchain cursor nodes otherwise.
+ */
+ callchain_cursor_copy(&cursor, &callchain_cursor);
+
+ he_self = add_hist_entry(self, al, sym_parent, period, true);
+ if (he_self == NULL)
+ return NULL;
+
+ callchain_cursor_next(&cursor);
+
+ /*
+ * map, sym and addr in al_child will be updated on a loop below.
+ * The other fields are kept same as original @al.
+ */
+ al_child = *al;
+
+ /* add all entries in the original callchain */
+ for (i = 1; i < callchain_cursor.nr; i++) {
+ if (callchain_cursor_peek_al(&cursor, &al_child))
+ return NULL;
+
+ /*
+ * XXX: Adding an entry without symbol information caused
+ * subtle problems. Just skip it for now.
+ */
+ if (al_child.sym == NULL) {
+ callchain_cursor_next(&cursor);
+ continue;
+ }
+
+ he = add_hist_entry(self, &al_child, sym_parent, period, false);
+ if (he == NULL)
+ return NULL;
+
+ if (callchain_append(he->callchain, &cursor, period))
+ return NULL;
+
+ callchain_cursor_next(&cursor);
+ }
+
+ return he_self;
+}
+
struct hist_entry *__hists__add_branch_entry(struct hists *self,
struct addr_location *al,
struct symbol *sym_parent,
@@ -418,6 +473,9 @@ struct hist_entry *__hists__add_entry(struct hists *self,
struct addr_location *al,
struct symbol *sym_parent, u64 period)
{
+ if (symbol_conf.cumulate_callchain)
+ return cumulate_hist_entry(self, al, sym_parent, period);
+
return add_hist_entry(self, al, sym_parent, period, true);
}
--
1.7.11.4
next prev parent reply other threads:[~2012-09-13 7:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-13 7:19 [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Namhyung Kim
2012-09-13 7:19 ` [PATCH 01/15] perf hists: Add missing period_* fields when collapsing a hist entry Namhyung Kim
2012-09-13 7:19 ` [PATCH 02/15] perf hists: Introduce struct he_stat Namhyung Kim
2012-09-13 7:19 ` [PATCH 03/15] perf hists: Move he->stat.nr_events initialization to a template Namhyung Kim
2012-09-13 7:20 ` [PATCH 04/15] perf hists: Convert hist entry functions to use struct he_stat Namhyung Kim
2012-09-13 7:20 ` [PATCH 05/15] perf hists: Add more helpers for hist entry stat Namhyung Kim
2012-09-13 7:20 ` [PATCH 06/15] perf hists: Add support for accumulated stat of hist entry Namhyung Kim
2012-09-13 7:20 ` [PATCH 07/15] perf hists: Check if accumulated when adding a " Namhyung Kim
2012-09-13 7:20 ` [PATCH 08/15] perf callchain: Add a couple of callchain helpers Namhyung Kim
2012-09-13 7:20 ` [PATCH 09/15] perf hists: Let add_hist_entry to make a hist entry template Namhyung Kim
2012-09-13 7:20 ` Namhyung Kim [this message]
2012-09-13 7:20 ` [PATCH 11/15] perf hists: Sort hist entries by accumulated period Namhyung Kim
2012-09-13 7:20 ` [PATCH 12/15] perf ui/hist: Add support to accumulated hist stat Namhyung Kim
2012-09-13 7:20 ` [PATCH 13/15] perf ui/browser: " Namhyung Kim
2012-09-13 7:20 ` [PATCH 14/15] perf ui/gtk: " Namhyung Kim
2012-09-13 7:20 ` [PATCH 15/15] perf report: Add --cumulate option Namhyung Kim
2012-09-20 17:33 ` [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Arun Sharma
2012-09-25 4:57 ` Namhyung Kim
2012-09-27 23:01 ` Frederic Weisbecker
2012-09-28 5:49 ` Namhyung Kim
2012-09-28 7:07 ` Stephane Eranian
2012-09-28 15:14 ` Frederic Weisbecker
2012-09-28 16:36 ` Stephane Eranian
2012-09-28 15:27 ` Frederic Weisbecker
2012-10-29 19:08 ` Peter Zijlstra
2012-10-29 21:36 ` Arun Sharma
2012-10-30 6:59 ` Namhyung Kim
2012-10-30 8:17 ` Peter Zijlstra
2012-10-30 9:01 ` Ingo Molnar
2012-10-31 7:24 ` Namhyung Kim
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=1347520811-28150-11-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=asharma@fb.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.org \
/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;
as well as URLs for NNTP newsgroup(s).