From: Al Grant <al.grant@foss.arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
acme@redhat.com, Denis Nikitin <denik@google.com>
Subject: Re: [PATCH] perf inject: correct event attribute sizes
Date: Wed, 26 Aug 2020 14:23:59 +0100 [thread overview]
Message-ID: <9a48bd74-42ad-4498-7f38-aed560031c4e@foss.arm.com> (raw)
In-Reply-To: <20200826112745.GB43491@C02TD0UTHF1T.local>
On 26/08/2020 12:27, Mark Rutland wrote:
> On Wed, Aug 26, 2020 at 10:42:04AM +0100, Al Grant 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.
>>
>> From: Denis Nikitin <denik@google.com>
>> Signed-off-by: Al Grant <al.grant@foss.arm.com>
>
> Did Denis write this patch?
Joint work - I fixed the sizes in the event attributes section,
but Denis noticed that the copies in HEADER_EVENT_DESC also need
fixing, so the final text is his.
> If so, we need an S-o-B line from them.
I have his approval to upstream this, so:
Signed-off-by: Denis Nikitin <denik@google.com>
Al
>
> Mark.
>
>> 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 9cf4efdcbbbd..762eb94bd532 100644
>> --- a/tools/perf/util/header.c
>> +++ b/tools/perf/util/header.c
>> @@ -3326,6 +3326,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);
>> + }
>> f_attr = (struct perf_file_attr){
>> .attr = evsel->core.attr,
>> .ids = {
next prev parent reply other threads:[~2020-08-26 13:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 9:42 [PATCH] perf inject: correct event attribute sizes Al Grant
2020-08-26 11:27 ` Mark Rutland
2020-08-26 13:23 ` Al Grant [this message]
2020-09-01 17:26 ` Arnaldo Carvalho de Melo
2020-11-24 19:58 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
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=9a48bd74-42ad-4498-7f38-aed560031c4e@foss.arm.com \
--to=al.grant@foss.arm.com \
--cc=acme@redhat.com \
--cc=denik@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
/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).