linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arun Sharma <asharma@fb.com>
To: linux-kernel@vger.kernel.org
Cc: Arun Sharma <asharma@fb.com>, Ingo Molnar <mingo@elte.hu>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Tom Zanussi <tzanussi@gmail.com>,
	linux-perf-users@vger.kernel.org
Subject: [PATCH 1/2] perf: refactor add_hist_entry() code paths
Date: Wed,  7 Mar 2012 14:41:18 -0800	[thread overview]
Message-ID: <1331160079-13821-2-git-send-email-asharma@fb.com> (raw)
In-Reply-To: <1331160079-13821-1-git-send-email-asharma@fb.com>

This makes perf__evsel_add_hist_entry() less busy in preparation
for support for sorting by inclusive times.

Signed-off-by: Arun Sharma <asharma@fb.com>
Cc: Ingo Molnar <mingo@elte.hu>
CC: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-perf-users@vger.kernel.org
---
 builtin-report.c |   12 ++++--------
 util/hist.c      |   20 ++++++++++++++++++++
 util/hist.h      |    5 +++++
 3 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/builtin-report.c b/builtin-report.c
index 25d34d4..72490a4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -61,6 +61,7 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
 	struct symbol *parent = NULL;
 	int err = 0;
 	struct hist_entry *he;
+	struct callchain_cursor *cursor;
 
 	if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
 		err = machine__resolve_callchain(machine, evsel, al->thread,
@@ -69,17 +70,12 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
 			return err;
 	}
 
-	he = __hists__add_entry(&evsel->hists, al, parent, sample->period);
+	cursor = &evsel->hists.callchain_cursor;
+	he = __hists__add_entry_single(&evsel->hists, al, parent,
+				       cursor, sample->period);
 	if (he == NULL)
 		return -ENOMEM;
 
-	if (symbol_conf.use_callchain) {
-		err = callchain_append(he->callchain,
-				       &evsel->hists.callchain_cursor,
-				       sample->period);
-		if (err)
-			return err;
-	}
 	/*
 	 * Only in the newt browser we are doing integrated annotation,
 	 * so we don't allocated the extra space needed because the stdio
diff --git a/util/hist.c b/util/hist.c
index 6f505d1..ca2314a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -252,6 +252,26 @@ out_unlock:
 	return he;
 }
 
+struct hist_entry *__hists__add_entry_single(struct hists *hists,
+					     struct addr_location *al,
+					     struct symbol *sym_parent,
+					     struct callchain_cursor *cursor,
+					     u64 period)
+{
+	struct hist_entry *he;
+	int err;
+
+	he = __hists__add_entry(hists, al, sym_parent, period);
+	if (he == NULL)
+		return NULL;
+	if (symbol_conf.use_callchain) {
+		err = callchain_append(he->callchain, cursor, period);
+		if (err)
+			return NULL;
+	}
+	return he;
+}
+
 int64_t
 hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
 {
diff --git a/util/hist.h b/util/hist.h
index 48e5acd..3ed726b 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -68,6 +68,11 @@ struct hists {
 struct hist_entry *__hists__add_entry(struct hists *self,
 				      struct addr_location *al,
 				      struct symbol *parent, u64 period);
+struct hist_entry *__hists__add_entry_single(struct hists *self,
+				      struct addr_location *al,
+				      struct symbol *parent,
+				      struct callchain_cursor *cursor,
+				      u64 period);
 int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right);
 int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right);
 int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
-- 
1.7.8.rc1

  reply	other threads:[~2012-03-07 22:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 22:41 [PATCH 0/2] perf: add sort by inclusive time functionality (v2) Arun Sharma
2012-03-07 22:41 ` Arun Sharma [this message]
2012-03-07 22:41 ` [PATCH 2/2] perf: Add a new sort order: SORT_INCLUSIVE Arun Sharma
2012-03-07 23:13   ` Arun Sharma
2012-03-08  7:22   ` Ingo Molnar
2012-03-12 19:35     ` Arun Sharma
2012-03-08 15:39   ` Frederic Weisbecker
2012-03-08 18:22     ` Arun Sharma
2012-03-13 13:44       ` Frederic Weisbecker
2012-03-08  7:29 ` [PATCH 0/2] perf: add sort by inclusive time functionality (v2) Ingo Molnar
2012-03-08 15:31   ` Frederic Weisbecker
2012-03-08 18:49     ` Arun Sharma
2012-03-12  7:15       ` Namhyung Kim
2012-03-12 18:05         ` Arun Sharma
2012-03-13  1:11           ` Namhyung Kim
2012-03-12  7:43 ` Namhyung Kim
2012-03-12 18:21   ` Arun Sharma
2012-03-12 19:58     ` Arun Sharma
2012-03-13  1:36       ` Namhyung Kim
2012-03-15 14:50         ` Frederic Weisbecker
2012-03-15 17:41           ` Arun Sharma
2012-03-13  1:16     ` Namhyung Kim
2012-03-13 18:45       ` Arun Sharma

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=1331160079-13821-2-git-send-email-asharma@fb.com \
    --to=asharma@fb.com \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=tzanussi@gmail.com \
    /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).