From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Denis Nikitin <denik@chromium.org>,
linux-perf-users@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, namhyung@kernel.org,
al.grant@arm.com, al.grant@foss.arm.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf inject: correct event attribute sizes
Date: Fri, 15 Jan 2021 16:48:25 -0300 [thread overview]
Message-ID: <20210115194825.GL457607@kernel.org> (raw)
In-Reply-To: <20201223221105.GA236568@krava>
Em Wed, Dec 23, 2020 at 11:11:05PM +0100, Jiri Olsa escreveu:
> On Tue, Dec 15, 2020 at 10:58:16PM -0800, Denis Nikitin wrote:
> > When perf inject reads a perf.data file from an older version of perf,
> > it writes event attributes into the output with the original size field,
> > but lays them out as if they had the size currently used. Readers see
> > a corrupt file. Update the size field to match the layout.
> >
> > Signed-off-by: Al Grant <al.grant@foss.arm.com>
> > Signed-off-by: Denis Nikitin <denik@chromium.org>
> > ---
> > tools/perf/util/header.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index be850e9f8852..0d95981df8dd 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -3331,6 +3331,14 @@ int perf_session__write_header(struct perf_session *session,
> > attr_offset = lseek(ff.fd, 0, SEEK_CUR);
> >
> > evlist__for_each_entry(evlist, evsel) {
> > + if (evsel->core.attr.size < sizeof(evsel->core.attr)) {
> > + /*
> > + * We are likely in "perf inject" and have read
> > + * from an older file. Update attr size so that
> > + * reader gets the right offset to the ids.
> > + */
> > + evsel->core.attr.size = sizeof(evsel->core.attr);
> > + }
>
> seems ok, just wondering if it would be better
> to fix it in perf_event__process_attr instead
>
> where we know where the data is coming from,
> here we could cover for some unexpected case
> of having different attr.size?
>
> anyway both would be probably equal, I'm ok
> with either way
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
Thanks, applied.
- Arnaldo
next prev parent reply other threads:[~2021-01-15 19:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 19:58 [PATCH] perf inject: correct event attribute sizes Al Grant
2020-12-16 6:58 ` Denis Nikitin
2020-12-23 22:11 ` Jiri Olsa
2021-01-15 19:48 ` Arnaldo Carvalho de Melo [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-26 9:42 Al Grant
2020-08-26 11:27 ` Mark Rutland
2020-08-26 13:23 ` Al Grant
2020-09-01 17:26 ` Arnaldo Carvalho de Melo
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=20210115194825.GL457607@kernel.org \
--to=acme@kernel.org \
--cc=al.grant@arm.com \
--cc=al.grant@foss.arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=denik@chromium.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@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).