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 2/8] perf jevents: Support --gen-dir/--gen-manifest overlay and ignore backups
Date: Sun, 06 Dec 2026 02:23:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-252061@kernel.org> (raw)
In-Reply-To: <20261206021147.3036701-3-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] perf jevents: duplicated JSON and backup filter rules from
  metric.py
--

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

perf jevents: Support --gen-dir/--gen-manifest overlay and ignore backups

This commit refactors jevents.py to collect JSON tables in memory, adds
--gen-dir, --gen-manifest, and --gen-file options for overlaying generated
JSON files, and filters out backup and hidden files.

> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 50bfce7d07d44..f4c6edd30d088 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py

[ ... ]

> @@ -91,6 +92,56 @@ _valid_keys: Set[str] = {
>      'ThreadMask', 'UMask', 'Unit',
>  }
>  
> +# Generated JSON filenames written into --gen-dir rather than starting_dir.
> +# Ignored in starting_dir when --gen-dir is supplied so leftover files from
> +# older in-tree builds cannot collide with freshly generated outputs.
> +_GENERATED_JSON_NAMES = frozenset({
> +    'legacy-cache.json',
> +    'extra-metrics.json',
> +    'extra-metricgroups.json',
> +})
> +
> +# Backup files created by git mergetool end in .json and would otherwise look
> +# like valid topic tables.
> +_MERGETOOL_BACKUP_RE = re.compile(r'_(?:BACKUP|BASE|LOCAL|REMOTE)_\d+\.json$')
> +
> +
> +def _is_valid_dir_name(name: str) -> bool:
> +  """Return True if a directory under arch/ should be traversed."""
> +  return not name.startswith('.') and '.' not in name
> +
> +
> +def _is_valid_json_filename(name: str, skip_generated: bool = False) -> bool:
> +  """Return True if filename looks like a PMU event/metric JSON table.
> +
> +  Skips hidden dotfiles (including Emacs '.#*' lockfiles), multi-dot backup
> +  copies (e.g. 'cache.bak.json', 'cache.orig.json'), git mergetool backups,
> +  and optionally generated filenames when scanning the source tree alongside
> +  an explicit --gen-dir.
> +  """
> +  if name.startswith('.') or not name.endswith('.json'):
> +    return False
> +  if name.count('.') != 1:
> +    return False
> +  if _MERGETOOL_BACKUP_RE.search(name):
> +    return False
> +  if skip_generated and name in _GENERATED_JSON_NAMES:
> +    return False
> +  return True

[Severity: Low]
Could _GENERATED_JSON_NAMES, _MERGETOOL_BACKUP_RE, _is_valid_dir_name(), and
the filename checks in _is_valid_json_filename() be shared with
tools/perf/pmu-events/metric.py instead of duplicated here?

jevents.py already imports metric, which defines the same
_MERGETOOL_BACKUP_RE, _SKIP_EVENT_JSON_NAMES, _is_valid_event_json(), and
dotted/hidden directory filter in LoadEvents().  Keeping two copies risks
metric generation and jevents compilation silently diverging if a new
generated JSON table or backup pattern is added to only one module.

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

  reply	other threads:[~2026-12-06  2:23 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 [this message]
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
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-252061@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