From: Ilkka Koskinen <ilkka@os.amperecomputing.com>
To: John Garry <john.g.garry@oracle.com>
Cc: irogers@google.com, acme@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
ilkka@os.amperecomputing.com
Subject: Re: [PATCH] perf jevents: Raise exception for no definition of a arch std event
Date: Wed, 9 Aug 2023 22:10:51 -0700 (PDT) [thread overview]
Message-ID: <373e8253-656c-84dc-c05-b578e3725d@os.amperecomputing.com> (raw)
In-Reply-To: <20230807111631.3033102-1-john.g.garry@oracle.com>
Hi John,
On Mon, 7 Aug 2023, John Garry wrote:
> Recently Ilkka reported that the JSONs for the AmpereOne arm64-based
> platform included a dud event which referenced a non-existent arch std
> event [0].
I wish I had found the bug in my patch a long time ago but, in fact, it
was Dave Kleikamp who initially pointed it out to me and figured out the
difference between jevents.c and jevents.py when porting the patch to 5.15
kernel.
http://lists.infradead.org/pipermail/linux-arm-kernel/2023-June/844874.html
>
> Previously in the times of jevents.c, we would raise an exception for this.
>
> This is still invalid, even though the current code just ignores such an
> event.
>
> Re-introduce code to raise an exception for when no definition exists to
> help catch as many invalid JSONs as possible.
>
> [0] https://lore.kernel.org/linux-perf-users/9e851e2a-26c7-ba78-cb20-be4337b2916a@oracle.com/
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
Thanks for the patch! I quickly tested it and it worked as expected. Just
in case this is needed:
Tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Cheers, Ilkka
> ---
> Please do not apply before [0], above.
>
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 8cd561aa606a..98cccc3fcbbd 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -347,12 +347,15 @@ class JsonEvent:
> if self.desc and not self.desc.endswith('. '):
> self.desc += '. '
> self.desc = (self.desc if self.desc else '') + ('Unit: ' + self.pmu + ' ')
> - if arch_std and arch_std.lower() in _arch_std_events:
> - event = _arch_std_events[arch_std.lower()].event
> - # Copy from the architecture standard event to self for undefined fields.
> - for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> - if hasattr(self, attr) and not getattr(self, attr):
> - setattr(self, attr, value)
> + if arch_std:
> + if arch_std.lower() in _arch_std_events:
> + event = _arch_std_events[arch_std.lower()].event
> + # Copy from the architecture standard event to self for undefined fields.
> + for attr, value in _arch_std_events[arch_std.lower()].__dict__.items():
> + if hasattr(self, attr) and not getattr(self, attr):
> + setattr(self, attr, value)
> + else:
> + raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
>
> self.event = real_event(self.name, event)
>
> --
> 2.35.3
>
>
next prev parent reply other threads:[~2023-08-10 5:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 11:16 [PATCH] perf jevents: Raise exception for no definition of a arch std event John Garry
2023-08-10 5:10 ` Ilkka Koskinen [this message]
2023-08-10 19:27 ` Ian Rogers
2023-08-21 10:46 ` John Garry
2023-08-21 13:01 ` Arnaldo Carvalho de Melo
2023-08-26 19:30 ` Ilkka Koskinen
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=373e8253-656c-84dc-c05-b578e3725d@os.amperecomputing.com \
--to=ilkka@os.amperecomputing.com \
--cc=acme@kernel.org \
--cc=irogers@google.com \
--cc=john.g.garry@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.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;
as well as URLs for NNTP newsgroup(s).