public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
	Don Zickus <dzickus@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 07/21] perf trace: Separate routine that handles an event from the one that reads it
Date: Wed, 25 Feb 2015 18:46:45 -0300	[thread overview]
Message-ID: <1424900819-910-8-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1424900819-910-1-git-send-email-acme@kernel.org>

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

Because we need to use ordered_events in some cases, so we will need to
first have them in a queue, order that queue, and then process the
event.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-cmkw9zgoh0z4r218957ftp1a@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c | 58 +++++++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 60ccfd52189d..fbdfb338bc38 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2092,10 +2092,39 @@ static int perf_evlist__add_pgfault(struct perf_evlist *evlist,
 	return 0;
 }
 
+static void trace__handle_event(struct trace *trace, union perf_event *event, struct perf_sample *sample)
+{
+	const u32 type = event->header.type;
+	struct perf_evsel *evsel;
+
+	if (!trace->full_time && trace->base_time == 0)
+		trace->base_time = sample->time;
+
+	if (type != PERF_RECORD_SAMPLE) {
+		trace__process_event(trace, trace->host, event, sample);
+		return;
+	}
+
+	evsel = perf_evlist__id2evsel(trace->evlist, sample->id);
+	if (evsel == NULL) {
+		fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample->id);
+		return;
+	}
+
+	if (evsel->attr.type == PERF_TYPE_TRACEPOINT &&
+	    sample->raw_data == NULL) {
+		fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
+		       perf_evsel__name(evsel), sample->tid,
+		       sample->cpu, sample->raw_size);
+	} else {
+		tracepoint_handler handler = evsel->handler;
+		handler(trace, evsel, event, sample);
+	}
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
 	struct perf_evlist *evlist = trace->evlist;
-	struct perf_evsel *evsel;
 	int err = -1, i;
 	unsigned long before;
 	const bool forks = argc > 0;
@@ -2190,8 +2219,6 @@ again:
 		union perf_event *event;
 
 		while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) {
-			const u32 type = event->header.type;
-			tracepoint_handler handler;
 			struct perf_sample sample;
 
 			++trace->nr_events;
@@ -2202,30 +2229,7 @@ again:
 				goto next_event;
 			}
 
-			if (!trace->full_time && trace->base_time == 0)
-				trace->base_time = sample.time;
-
-			if (type != PERF_RECORD_SAMPLE) {
-				trace__process_event(trace, trace->host, event, &sample);
-				continue;
-			}
-
-			evsel = perf_evlist__id2evsel(evlist, sample.id);
-			if (evsel == NULL) {
-				fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample.id);
-				goto next_event;
-			}
-
-			if (evsel->attr.type == PERF_TYPE_TRACEPOINT &&
-			    sample.raw_data == NULL) {
-				fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
-				       perf_evsel__name(evsel), sample.tid,
-				       sample.cpu, sample.raw_size);
-				goto next_event;
-			}
-
-			handler = evsel->handler;
-			handler(trace, evsel, event, &sample);
+			trace__handle_event(trace, event, &sample);
 next_event:
 			perf_evlist__mmap_consume(evlist, i);
 
-- 
1.9.3


  parent reply	other threads:[~2015-02-25 21:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 21:46 [GIT PULL 00/21] perf/record improvements and fixes Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 01/21] perf trace: Only insert blank duration bracket when tracing syscalls Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 02/21] perf evlist: Introduce set_filter_pid method Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 03/21] perf trace: Filter out the trace pid when no threads are specified Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 04/21] perf evlist: Introduce set_filter_pids method Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 05/21] perf trace: Introduce --filter-pids Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 06/21] perf trace: Add man page entry for --event Arnaldo Carvalho de Melo
2015-02-25 21:46 ` Arnaldo Carvalho de Melo [this message]
2015-02-25 21:46 ` [PATCH 08/21] perf session: Remove wrappers to machines__find Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 09/21] perf evlist: Adopt events_stats from perf_session Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 10/21] perf session: Remove perf_session from warn_errors signature Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 11/21] perf session: Remove perf_session from some deliver event routines Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 12/21] perf session: Remove perf_session from dump_event Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 13/21] perf ordered_events: Stop using tool->ordered_events Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 14/21] perf tools: Introduce dump_stack signal helper Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 15/21] perf trace: Dump stack on segfaults Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 16/21] perf tools: Print the thread's tid on PERF_RECORD_COMM events when -D is asked Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 17/21] perf record: Support recording running/enabled time Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 18/21] perf tools: Add feature check for libbabeltrace Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 19/21] perf tools: Add new 'perf data' command Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 20/21] perf data: Add perf data to CTF conversion support Arnaldo Carvalho de Melo
2015-02-25 21:46 ` [PATCH 21/21] perf data: Add a 'perf' prefix to the generic fields Arnaldo Carvalho de Melo
2015-02-25 21:53 ` [GIT PULL 00/21] perf/record improvements and fixes Arnaldo Carvalho de Melo
2015-02-26 11:27 ` 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=1424900819-910-8-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=dsahern@gmail.com \
    --cc=dzickus@redhat.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@kernel.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