From: sashiko-bot@kernel.org
To: "TAKANO Mitsuhiro" <takano32@gmail.com>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf jevents: Check the JSON keys that jevents.py never reads
Date: Tue, 10 Nov 2026 19:45:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-207678@kernel.org> (raw)
In-Reply-To: <20261110193239.1741014-1-takano32@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] perf jevents: crash in _read_json_events_impl() when MetricExpr
is mistyped
- [Low] perf jevents: preprocess_arch_std_files() drops parse error in
--check mode
--
commit b85ceb11b01de607fd5251f8da36bf8900130730
Author: TAKANO Mitsuhiro <takano32@gmail.com>
perf jevents: Check the JSON keys that jevents.py never reads
This commit adds a --check mode to jevents.py (and a jevents-check make
target) that tracks unread JSON keys in JsonEvent and reports keys that
closely match field names read by jevents.py.
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 080e04b51b8c5..56859e983a4b0 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
[ ... ]
> @@ -493,7 +653,10 @@ def preprocess_arch_std_files(archpath: str) -> None:
> if event.metric_name:
> _arch_std_events[event.metric_name.lower()] = event
> except Exception as e:
> - raise RuntimeError(f'Failure processing \'{item.name}\' in \'{archpath}\'') from e
> + failure = RuntimeError(f'Failure processing \'{item.name}\' in \'{archpath}\'')
> + if failures is None:
> + raise failure from e
> + failures.append((item.path, failure))
[Severity: Low]
Does appending failure instead of e here drop the underlying parse error when
--check reports failures from preprocess_arch_std_files()?
In main(), each entry in failed is printed with str(error), which does not
follow __cause__ and only prints "Failure processing '<name>' in '<archpath>'"
alongside the relative path, hiding why the JSON file failed to load.
[ ... ]
> @@ -1490,12 +1660,111 @@ such as "arm/cortex-a34".''',
[ ... ]
> + with concurrent.futures.ProcessPoolExecutor(max_workers=_parallel_worker_count(len(tasks)),
> + initializer=_init_worker,
> + initargs=(_arch_std_events, _args.check)) as executor:
> + for path, topic, events in executor.map(_parallel_read_json_events, tasks):
> + if isinstance(events, Exception):
> + if not _args.check:
> + raise RuntimeError(f'Failure processing \'{path}\'') from events
> + failed.append((path, events))
> + else:
> + _json_cache[(path, topic)] = events
[Severity: Low]
What happens in --check mode when a metric object has a valid MetricName
(without '-') but misspells MetricExpr (for example as MetricExp)?
JsonEvent.__init__() leaves self.metric_expr as None and records the mistyped
key in self.mistyped, but _read_json_events_impl() then passes that None
expression into metric.RewriteMetricsInTermsOfOthers():
tools/perf/pmu-events/jevents.py:_read_json_events_impl() {
...
for event in events:
event.topic = topic
if event.metric_name and '-' not in event.metric_name:
metrics.append((event.pmu, event.metric_name, event.metric_expr))
updates = metric.RewriteMetricsInTermsOfOthers(metrics)
...
}
RewriteMetricsInTermsOfOthers() raises an AttributeError on None before
_read_json_events_impl() can return events, so main() records the file in
failed instead of _json_cache and --check reports an AttributeError (exit
status 2) instead of reporting the misspelled MetricExpr key. Checking that
event.metric_expr is not None before appending to metrics would let --check
report the misspelling.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110193239.1741014-1-takano32@gmail.com?part=1
prev parent reply other threads:[~2026-11-10 19:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 19:32 [PATCH] perf jevents: Check the JSON keys that jevents.py never reads TAKANO Mitsuhiro
2026-11-10 19:45 ` sashiko-bot [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=sashiko-outbox-207678@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=takano32@gmail.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