public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Michael Petlan <mpetlan@redhat.com>
Subject: Re: [PATCH] perf session: Try to read pipe data from file
Date: Tue, 5 May 2020 00:57:07 +0200	[thread overview]
Message-ID: <20200504225325.GE1916255@krava> (raw)
In-Reply-To: <20200501113448.1809037-1-jolsa@kernel.org>

On Fri, May 01, 2020 at 01:34:47PM +0200, Jiri Olsa wrote:
> From: Jiri Olsa <jolsa@redhat.com>
> 
> Ian came with the idea of having support to read the pipe
> data also from file [1]. Currently pipe mode files fails
> like:
> 
>   $ perf record -o - sleep 1 > /tmp/perf.pipe.data
>   $ perf report -i /tmp/perf.pipe.data
>   incompatible file format (rerun with -v to learn more)
> 
> This patch adds the support to do that by trying the pipe
> header first, and if its successfully detected, switching
> the perf data to pipe mode.
> 
> [1] https://lore.kernel.org/lkml/20200409185744.255881-1-irogers@google.com/
> Original-patch-by: Ian Rogers <irogers@google.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

actualy.. I found another issue while trying this on tracepoints:

  # ./perf record -g  -e 'raw_syscalls:sys_enter' -o -  true > data
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB - ]
  # ./perf script -i ./data
  perf_event__process_tracing_data: tracing data size mismatch0x1034 [0xc]: failed to process type: 66

it's because some of the pipe synthesize code calls lseek, which
fails on pipe, but succeeds on normal file (with pipe data)

patch below fixes that for me, but I wonder there are other leftovers
like this.. I'll check on post it all together

jirka


---
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 8ca709f938b8..33e299674121 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3955,13 +3955,8 @@ int perf_event__process_tracing_data(struct perf_session *session,
 {
 	ssize_t size_read, padding, size = event->tracing_data.size;
 	int fd = perf_data__fd(session->data);
-	off_t offset = lseek(fd, 0, SEEK_CUR);
 	char buf[BUFSIZ];
 
-	/* setup for reading amidst mmap */
-	lseek(fd, offset + sizeof(struct perf_record_header_tracing_data),
-	      SEEK_SET);
-
 	size_read = trace_report(fd, &session->tevent,
 				 session->repipe);
 	padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c11d89e0ee55..b75df19feaf1 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1543,7 +1543,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,
 		return 0;
 	case PERF_RECORD_HEADER_TRACING_DATA:
 		/* setup for reading amidst mmap */
-		lseek(fd, file_offset, SEEK_SET);
+		if (!perf_data__is_pipe(session->data))
+			lseek(fd, file_offset, SEEK_SET);
 		return tool->tracing_data(session, event);
 	case PERF_RECORD_HEADER_BUILD_ID:
 		return tool->build_id(session, event);


  parent reply	other threads:[~2020-05-04 22:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 11:34 [PATCH] perf session: Try to read pipe data from file Jiri Olsa
2020-05-01 17:49 ` Ian Rogers
2020-05-04 22:57 ` Jiri Olsa [this message]
2020-05-04 23:27   ` Ian Rogers

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=20200504225325.GE1916255@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.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