Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 4/8] perf pmu-events: Batch metric generation and scope via mapfile.csv
Date: Sun, 06 Dec 2026 02:28:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-252064@kernel.org> (raw)
In-Reply-To: <20261206021147.3036701-5-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf pmu-events: missing assert on _args in generate_model()
  breaks mypy
--

commit 6bfab9e49f5b6e421aa597a42d3e2b3c68425bb1
Author: Ian Rogers <irogers@google.com>

perf pmu-events: Batch metric generation and scope via mapfile.csv

This commit adds mapfile.csv vendor scoping and multi-model batch helpers to
metric.py, and extends amd_metrics.py, arm64_metrics.py, and intel_metrics.py
with an --output-dir option to generate multiple models in one process.

> diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py
> index 42569b9153f45..3768fa875cd54 100755
> --- a/tools/perf/pmu-events/amd_metrics.py
> +++ b/tools/perf/pmu-events/amd_metrics.py

[ ... ]

> @@ -508,37 +508,55 @@ def main() -> None:

[ ... ]

>      _args = parser.parse_args()
> +    if _args.output_dir and _args.metricgroups:
> +        parser.error("--output-dir cannot be combined with -metricgroups")
> +    if not _args.output_dir and "," in _args.model:
> +        parser.error("Multiple comma-separated models require --output-dir")
> +
> +    def generate_model(model: str, preloaded_all_events=None) -> MetricGroup:
> +        global _zen_model
> +        _args.model = model
> +        directory = f"{_args.events_path}/x86/{model}/"

[Severity: Medium]
Does accessing _args inside generate_model() break mypy?

Module-level _args is initialized to None, so mypy types it as
Optional[argparse.Namespace] and does not carry narrowing into the typed
nested function generate_model().  This produces union-attr errors on
_args.model and _args.events_path, breaking mypy-pmu-events during builds.

The same issue occurs in generate_model() in arm64_metrics.py (which also
accesses _args.vendor) and intel_metrics.py.  Adding "assert _args is not
None" at the start of generate_model() in all three scripts matches
scan_arch_tree() in jevents.py.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206021147.3036701-1-irogers@google.com?part=4

  reply	other threads:[~2026-12-06  2:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  2:11 [PATCH 0/8] perf build: Avoid pmu-events copies and improve build parallelism Ian Rogers
2026-12-06  2:11 ` [PATCH 1/8] perf pmu-events: Ignore backup and non-event JSON files in metric.py Ian Rogers
2026-12-06  2:22   ` sashiko-bot
2026-12-06  2:11 ` [PATCH 2/8] perf jevents: Support --gen-dir/--gen-manifest overlay and ignore backups Ian Rogers
2026-12-06  2:23   ` sashiko-bot
2026-12-06  2:11 ` [PATCH 3/8] perf build: Avoid copying pmu-events JSON files into OUTPUT Ian Rogers
2026-12-06  2:26   ` sashiko-bot
2026-12-06  2:11 ` [PATCH 4/8] perf pmu-events: Batch metric generation and scope via mapfile.csv Ian Rogers
2026-12-06  2:28   ` sashiko-bot [this message]
2026-12-06  2:11 ` [PATCH 5/8] perf build: Batch metric JSON generation in pmu-events/Build Ian Rogers
2026-12-06  2:26   ` sashiko-bot
2026-12-06  2:11 ` [PATCH 6/8] perf build: Run pmu-events tests in parallel with jevents.py Ian Rogers
2026-12-06  2:11 ` [PATCH 7/8] perf build: Depend on lib*-headers instead of archives in prepare Ian Rogers
2026-12-06  2:11 ` [PATCH 8/8] perf tests make: Only run shellcheck, mypy and pylint in pure builds Ian Rogers
2026-12-06  2:22   ` sashiko-bot
2026-12-06  2:28 ` [PATCH 0/8] perf build: Avoid pmu-events copies and improve build parallelism sashiko-bot

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-252064@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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