mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 08/18] perf evlist: Introduce perf_evlist__parse_sample
Date: Fri,  3 Aug 2012 11:01:00 -0300	[thread overview]
Message-ID: <1344002470-5965-9-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1344002470-5965-1-git-send-email-acme@infradead.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

That is a more compact form of perf_session__parse_sample and to support
multiple evlists per perf_session is the way to go anyway.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-vkxx3j5qktoj11bvcwmfjj13@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-test.c |    8 ++------
 tools/perf/builtin-top.c  |    2 +-
 tools/perf/util/evlist.c  |    9 +++++++++
 tools/perf/util/evlist.h  |    4 ++++
 tools/perf/util/python.c  |    6 +-----
 tools/perf/util/session.c |   19 ++++---------------
 tools/perf/util/session.h |    4 ----
 7 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index e5032ed..1d592f5 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -562,9 +562,7 @@ static int test__basic_mmap(void)
 			goto out_munmap;
 		}
 
-		err = perf_event__parse_sample(event, attr.sample_type,
-					       evsels[0]->sample_size,
-					       false, &sample, false);
+		err = perf_evlist__parse_sample(evlist, event, &sample, false);
 		if (err) {
 			pr_err("Can't parse sample, err = %d\n", err);
 			goto out_munmap;
@@ -781,9 +779,7 @@ static int test__PERF_RECORD(void)
 				if (type < PERF_RECORD_MAX)
 					nr_events[type]++;
 
-				err = perf_event__parse_sample(event, evsel->attr.sample_type,
-							       evsel->sample_size, true,
-							       &sample, false);
+				err = perf_evlist__parse_sample(evlist, event, &sample, false);
 				if (err < 0) {
 					if (verbose)
 						perf_event__fprintf(event, stderr);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 520e425..40264ea 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -811,7 +811,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
 	int ret;
 
 	while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) {
-		ret = perf_session__parse_sample(session, event, &sample);
+		ret = perf_evlist__parse_sample(top->evlist, event, &sample, false);
 		if (ret) {
 			pr_err("Can't parse sample, err = %d\n", ret);
 			continue;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3edfd34..1a560e0 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -881,3 +881,12 @@ int perf_evlist__start_workload(struct perf_evlist *evlist)
 
 	return 0;
 }
+
+int perf_evlist__parse_sample(struct perf_evlist *evlist,
+			      const union perf_event *event,
+			      struct perf_sample *sample, bool swapped)
+{
+	struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node);
+	return perf_event__parse_sample(event, e->attr.sample_type, e->sample_size,
+					e->attr.sample_id_all, sample, swapped);
+}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 40d4d3c..a5a4911 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -122,6 +122,10 @@ u64 perf_evlist__sample_type(const struct perf_evlist *evlist);
 bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist);
 u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist);
 
+int perf_evlist__parse_sample(struct perf_evlist *evlist,
+			      const union perf_event *event,
+			      struct perf_sample *sample, bool swapped);
+
 bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist);
 bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist);
 
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index b0d6f85..0688bfb 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -797,17 +797,13 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
 
 	event = perf_evlist__mmap_read(evlist, cpu);
 	if (event != NULL) {
-		struct perf_evsel *first;
 		PyObject *pyevent = pyrf_event__new(event);
 		struct pyrf_event *pevent = (struct pyrf_event *)pyevent;
 
 		if (pyevent == NULL)
 			return PyErr_NoMemory();
 
-		first = list_entry(evlist->entries.next, struct perf_evsel, node);
-		err = perf_event__parse_sample(event, first->attr.sample_type,
-					       first->sample_size,
-					       sample_id_all, &pevent->sample, false);
+		err = perf_evlist__parse_sample(evlist, event, &pevent->sample, false);
 		if (err)
 			return PyErr_Format(PyExc_OSError,
 					    "perf: can't parse sample, err=%d", err);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 5b8601d..7d07324 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -16,19 +16,6 @@
 #include "cpumap.h"
 #include "event-parse.h"
 
-int perf_session__parse_sample(struct perf_session *session,
-			       const union perf_event *event,
-			       struct perf_sample *sample)
-{
-	struct perf_evsel *first;
-	first = list_entry(session->evlist->entries.next, struct perf_evsel, node);
-
-	return perf_event__parse_sample(event, first->attr.sample_type,
-					first->sample_size,
-					first->attr.sample_id_all, sample,
-					session->header.needs_swap);
-}
-
 int perf_session__synthesize_sample(struct perf_session *session,
 				    union perf_event *event,
 				    const struct perf_sample *sample)
@@ -692,7 +679,8 @@ static void flush_sample_queue(struct perf_session *s,
 		if (iter->timestamp > limit)
 			break;
 
-		ret = perf_session__parse_sample(s, iter->event, &sample);
+		ret = perf_evlist__parse_sample(s->evlist, iter->event, &sample,
+						s->header.needs_swap);
 		if (ret)
 			pr_err("Can't parse sample, err = %d\n", ret);
 		else
@@ -1103,7 +1091,8 @@ static int perf_session__process_event(struct perf_session *session,
 	/*
 	 * For all kernel events we get the sample data
 	 */
-	ret = perf_session__parse_sample(session, event, &sample);
+	ret = perf_evlist__parse_sample(session->evlist, event, &sample,
+					session->header.needs_swap);
 	if (ret)
 		return ret;
 
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index e2a1a4b..7389fb1 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -126,10 +126,6 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *self,
 
 size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
 
-int perf_session__parse_sample(struct perf_session *session,
-			       const union perf_event *event,
-			       struct perf_sample *sample);
-
 int perf_session__synthesize_sample(struct perf_session *session,
 				    union perf_event *event,
 				    const struct perf_sample *sample);
-- 
1.7.1


  parent reply	other threads:[~2012-08-03 14:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03 14:00 [GIT PULL 00/18] perf/core fixes and improvements Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 01/18] perf test: Fix parse events automated tests Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 02/18] perf symbols: Fix array sizes for binary types arrays Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 03/18] perf target: Fix check on buffer size Arnaldo Carvalho de Melo
2012-08-03 14:17   ` Kirill A. Shutemov
2012-08-06  3:53     ` Namhyung Kim
2012-08-06  4:14       ` David Ahern
2012-08-06  4:15         ` Namhyung Kim
2012-08-03 14:00 ` [PATCH 04/18] perf evsel: Precalculate the sample size Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 05/18] perf session: Use perf_evlist__sample_type more extensively Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 06/18] perf session: Use perf_evlist__sample_id_all " Arnaldo Carvalho de Melo
2012-08-03 14:00 ` [PATCH 07/18] perf session: Use perf_evlist__id_hdr_size " Arnaldo Carvalho de Melo
2012-08-03 14:01 ` Arnaldo Carvalho de Melo [this message]
2012-08-03 15:24   ` [PATCH 08/18] perf evlist: Introduce perf_evlist__parse_sample David Ahern
2012-08-03 17:28     ` Stephane Eranian
2012-08-03 14:01 ` [PATCH 09/18] perf evsel: Adopt parse_sample method from perf_event Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 10/18] perf session: Remove no longer used synthesize_sample method Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 11/18] perf top: Error handling for counter creation should parallel perf-record Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 12/18] perf tool: Save cmdline from user in file header vs what is passed to record Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 13/18] perf kvm: Use strtol for walking guestmount directory Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 14/18] perf tools: Introducing rblist Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 15/18] perf tools: Change strlist to use the new rblist Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 16/18] perf tools: Introduce intlist Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 17/18] perf kvm top: Limit guest kernel info message to once Arnaldo Carvalho de Melo
2012-08-03 14:01 ` [PATCH 18/18] perf tools: Remove brace expansion from clean target Arnaldo Carvalho de Melo
2012-08-05 10:40 ` [GIT PULL 00/18] perf/core fixes and improvements Ingo Molnar

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=1344002470-5965-9-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®