From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 5/8] perf build: Batch metric JSON generation in pmu-events/Build
Date: Sun, 06 Dec 2026 02:26:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-252062@kernel.org> (raw)
In-Reply-To: <20261206021147.3036701-6-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] perf build: metric stamps newer than JSON outputs break
incremental builds
- [Low] perf build: missing generated metric JSONs not regenerated under
stamp rules
- [Low] perf build: metric stamp files not removed before in-place JSON
overwrite
--
commit 1a536b4cc22c128125cad68b8bd0a9a6945e00bd
Author: Ian Rogers <irogers@google.com>
perf build: Batch metric JSON generation in pmu-events/Build
This commit replaces the 136 per-model metric JSON build rules in
tools/perf/pmu-events/Build with three stamp-gated batch invocations
for AMD, Intel, and ARM64.
> diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
> index 22e4db88272f3..c0f6855a17c97 100644
> --- a/tools/perf/pmu-events/Build
> +++ b/tools/perf/pmu-events/Build
[ ... ]
> @@ -94,59 +98,65 @@ $(LEGACY_CACHE_JSON): $(LEGACY_CACHE_PY)
[ ... ]
> +$(ZEN_METRICS_STAMP): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS) $(SRC_ZEN_JSON) $(JEVENTS_SRC_MANIFEST)
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) $(SRC_DIR) > $@
> + $(Q)$(call echo-cmd,gen)$(PYTHON) $< --output-dir $(GEN_DIR) \
> + $(subst $(space),$(comma),$(strip $(ZENS))) $(SRC_DIR) && touch $@
[Severity: Medium]
Does running touch $@ after $(PYTHON) finishes leave the stamp file newer
than every generated JSON output?
The batch scripts write all JSON files before touch $@ runs, and the @:
rules do not update their mtimes. Every incremental build (entered via
FORCE on LIBPMU_EVENTS_IN in tools/perf/Makefile.perf) therefore treats
all 136 JSON targets as out of date, spawning /bin/sh -c : 136 times.
The same applies to INTEL_METRICS_STAMP and ARM_METRICS_STAMP. Creating a
temporary timestamp file before invoking $(PYTHON) and moving it into $@
on success would keep the stamp mtime at or before the generated outputs.
[Severity: Low]
Can a failed or interrupted regeneration leave a pre-existing stamp file
intact over truncated or mixed-version JSON outputs?
WriteMetricsOutput() in tools/perf/pmu-events/metric.py opens each model
JSON directly with 'w', truncating it in place. If the script fails or is
interrupted mid-run (for example during make -B), && touch $@ never runs,
so $@'s mtime is unchanged and .DELETE_ON_ERROR will not delete it.
Later incremental builds then treat the surviving stamp as up to date and
either fail in jevents.py or compile mixed-version metrics. Removing $@
before invoking $(PYTHON) (and using atomic replacement in
WriteMetricsOutput()) avoids this; the same applies to Intel and ARM64.
> -$(ZEN_METRICGROUPS): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS)
> - $(call rule_mkdir)
> - $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) $(SRC_DIR) > $@
> +$(ZEN_METRICS) $(ZEN_METRICGROUPS): $(ZEN_METRICS_STAMP)
> + @:
[Severity: Low]
What happens if an individual generated JSON file is missing while its
stamp file is still up to date?
Previously each JSON file had its own rule, so Make regenerated any
missing output. With the bare @: recipe, Make silently satisfies a
missing output and jevents.py aborts with FileNotFoundError on every
subsequent make until the stamp is removed or make clean is run.
The same applies to the Intel and ARM64 rules. Forcing regeneration when
any expected output is absent (for example via $(wildcard ...) on the
stamp prerequisite or checking test -f $@) would restore recovery.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206021147.3036701-1-irogers@google.com?part=5
next prev parent reply other threads:[~2026-12-06 2:26 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
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 [this message]
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-252062@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.