From: Jiri Olsa <jolsa@redhat.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexey Budankov <alexey.budankov@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf data: if a bad header size, retry in pipe mode
Date: Thu, 30 Apr 2020 17:34:44 +0200 [thread overview]
Message-ID: <20200430153444.GG1694693@krava> (raw)
In-Reply-To: <CAP-5=fW0+FyFkakrYL6MYYYSQ_8F8kP+AhZ6W1Aqgophegzamg@mail.gmail.com>
On Thu, Apr 30, 2020 at 07:12:49AM -0700, Ian Rogers wrote:
> On Tue, Apr 14, 2020 at 7:01 AM Ian Rogers <irogers@google.com> wrote:
> >
> > On Tue, Apr 14, 2020 at 5:51 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > >
> > > On Thu, Apr 09, 2020 at 11:57:44AM -0700, Ian Rogers wrote:
> > > > Currently pipe mode files fail 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 change makes it so that if a perf.data file's header size is wrong
> > > > it is re-checked in pipe mode, where if wrong it fails as it currently
> > > > does.
> > > >
> > >
> > > hi,
> > > how about doing it the other way round like below,
> > > read header and find out if it's pipe..
> > >
> > > seems it's less changes
> > >
> > > jirka
> >
> > Looks good to me. I think removing the function declaration from
> > util/header.h is still worthwhile, but needn't be in a patch with this
> > change.
>
> Hi Jiri,
>
> Do you need to send this patch?
ah right, will post, thanks for reminder
jirka
>
> Thanks,
> Ian
>
> > Thanks!
> > Ian
> >
> > > ---
> > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > > index acbd046bf95c..20c34cec9a46 100644
> > > --- a/tools/perf/util/header.c
> > > +++ b/tools/perf/util/header.c
> > > @@ -3469,7 +3469,7 @@ static int perf_header__read_pipe(struct perf_session *session)
> > > return -EINVAL;
> > > }
> > >
> > > - return 0;
> > > + return f_header.size == sizeof(f_header) ? 0 : -1;
> > > }
> > >
> > > static int read_attr(int fd, struct perf_header *ph,
> > > @@ -3571,7 +3571,7 @@ int perf_session__read_header(struct perf_session *session)
> > > struct perf_file_header f_header;
> > > struct perf_file_attr f_attr;
> > > u64 f_id;
> > > - int nr_attrs, nr_ids, i, j;
> > > + int nr_attrs, nr_ids, i, j, err;
> > > int fd = perf_data__fd(data);
> > >
> > > session->evlist = evlist__new();
> > > @@ -3580,8 +3580,16 @@ int perf_session__read_header(struct perf_session *session)
> > >
> > > session->evlist->env = &header->env;
> > > session->machines.host.env = &header->env;
> > > - if (perf_data__is_pipe(data))
> > > - return perf_header__read_pipe(session);
> > > +
> > > + /*
> > > + * We could still read 'pipe' data from regular file,
> > > + * check for the pipe header first.
> > > + */
> > > + err = perf_header__read_pipe(session);
> > > + if (!err || (err && perf_data__is_pipe(data))) {
> > > + data->is_pipe = true;
> > > + return err;
> > > + }
> > >
> > > if (perf_file_header__read(&f_header, header, fd) < 0)
> > > return -EINVAL;
> > >
>
prev parent reply other threads:[~2020-04-30 15:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 18:57 [PATCH] perf data: if a bad header size, retry in pipe mode Ian Rogers
2020-04-14 12:51 ` Jiri Olsa
2020-04-14 14:01 ` Ian Rogers
2020-04-30 14:12 ` Ian Rogers
2020-04-30 15:34 ` Jiri Olsa [this message]
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=20200430153444.GG1694693@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexey.budankov@linux.intel.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).