From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 10/11] perf list: Add --export-cpuid to export compiled-in CPU models
Date: Fri, 04 Dec 2026 01:44:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-248910@kernel.org> (raw)
In-Reply-To: <20261204011029.1946921-11-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [Low] perf list: missing strings.h include for strcasecmp() in
builtin-list.c
- [Low] perf list: cmd_list__export_cpuid() depends on host sysfs PMUs
for --cputype
- [Low] perf: export_cpuid_metric_cb() omits sys symlink on
metricgroup-only export
- [Low] perf: expand_cpuid_pattern() duplicates jevents.py CPUID regex
expansion
- [Low] perf: arch_or_model_matches() inconsistently aliases test to
testarch
- [Low] perf: commit message claims nonexistent metricgroups dir for
neoverse-n2-v2
- [Low] perf: export_builtin_pe/pm_to_dir() repeats mkdir_p and
open/close per entry
- [Low] perf: export_metric_groups_for_pm() lacks visited-group
deduplication
--
commit 6ad29d645c62d1cd976d7e2c369faa67835e31f0
Author: Ian Rogers <irogers@google.com>
perf list: Add --export-cpuid to export compiled-in CPU models
This commit adds --export-cpuid to perf list (for use with --export-dir)
and implements pmu_layer__export_cpuid() so compiled-in event, metric, and
metricgroup tables for any CPUID, model, or architecture can be exported
directly from the perf binary into models/, cpus/, and sys/ directories.
> For example, to inspect or migrate metrics from ARM64 Neoverse-N2 onto
> another machine:
>
> $ perf list --export-dir /tmp/n2 \
> --export-cpuid arm64/arm/neoverse-n2-v2 metric metricgroup
>
> produces:
>
> /tmp/n2/
> |-- cpus/
> | |-- 0x00000000410fd490 -> ../models/arm64/arm/neoverse-n2-v2
> | `-- 0x00000000410fd4f0 -> ../models/arm64/arm/neoverse-n2-v2
> `-- models/arm64/arm/neoverse-n2-v2/
> |-- default_core/metrics/...
> `-- metricgroups/...
[Severity: Low]
Does this example actually create the metricgroups/ directory?
Neither arm64/arm/neoverse-n2-v2 nor arch/common/common has a
metricgroups.json file, so pmu_metrics_table__describe_metricgroup()
returns NULL and pmu_layer__export_metricgroup() skips creating
metricgroups/.
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 85de0bd73e324..f87a8b2147d46 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -703,6 +703,140 @@ static int list__tui(int argc, const char **argv)
[ ... ]
> + if (unit_name) {
> + base_pmu_glob = unit_name;
> + } else if (cputype) {
> + const struct perf_pmu *pmu = perf_pmus__pmu_for_pmu_filter(cputype);
> +
> + if (pmu)
> + base_pmu_glob = pmu->name;
[Severity: Low]
Does resolving --cputype via perf_pmus__pmu_for_pmu_filter() make
--export-cpuid output depend on the running host's sysfs PMUs?
perf_pmus__pmu_for_pmu_filter() scans host sysfs PMUs to expand short
names by stripping uncore_ or cpu_ prefixes. Exporting x86/skylake with
--cputype arb therefore exports uncore_arb on an Intel host that has that
PMU in sysfs, but exports nothing on an ARM64 or AMD host. Matching the
uncore_/cpu_ prefixes directly in export_cpuid_pmu_matches() would keep
the filter host-independent.
> + else if (!strcasecmp(cputype, "core"))
> + base_pmu_glob = "cpu_core";
> + else if (!strcasecmp(cputype, "atom"))
> + base_pmu_glob = "cpu_atom";
[Severity: Low]
Should builtin-list.c include <strings.h> for strcasecmp()?
The file includes <string.h> but not the POSIX-specified <strings.h>
header, so it currently relies on -D_GNU_SOURCE pulling the declaration in
transitively.
> diff --git a/tools/perf/util/pmu-layer.c b/tools/perf/util/pmu-layer.c
> index 5e28002b0bb49..166ecaa0db29f 100644
> --- a/tools/perf/util/pmu-layer.c
> +++ b/tools/perf/util/pmu-layer.c
[ ... ]
> +static int expand_cpuid_pattern(const char *arch, const char *pattern,
> + struct export_str_vec *out)
[Severity: Low]
Is it worth duplicating jevents.py's mapfile.csv regex expansion in C?
expand_regex_fragment(), expand_cpuid_pattern(), and is_literal_compat()
re-implement the architecture-specific pattern rules from
tools/perf/pmu-events/jevents.py (_expand_cpuid_pattern() and helpers), so
future mapfile.csv syntax changes have to be kept in sync in two places.
The two exporters also already diverge on the test architecture, where
jevents.py writes models/test/ while pmu_layer__export_cpuid() writes
models/testarch/.
[ ... ]
> + ret = pmu_layer__mkdir_p(dir_path);
> + if (ret == 0) {
> + fd = open(dir_path, O_RDONLY | O_DIRECTORY);
> + if (fd < 0) {
> + ret = -errno;
> + } else {
> + ret = export_write_alias_files(fd, enc_name, alias);
> + close(fd);
> + }
> }
> + perf_pmu_free_alias(alias);
> + return ret;
> +}
> +
> +static int export_builtin_pm_to_dir(const char *target_root,
> + const struct pmu_metric *pm)
> +{
[ ... ]
> + ret = pmu_layer__mkdir_p(dir_path);
> + if (ret < 0)
> + return ret;
> +
> + fd = open(dir_path, O_RDONLY | O_DIRECTORY);
> + if (fd < 0)
> + return -errno;
>
> + ret = export_write_pm_files(fd, enc_name, pm, true, true,
> + pm->default_show_events, true);
> close(fd);
> return ret;
> }
[Severity: Low]
Can export_table_walk_ctx cache the open events/metrics directory fd per
(target_root, eff_pmu)?
pmu_events_table__for_each_event() and
pmu_metrics_table__for_each_pmu_metric() visit entries grouped by PMU, so
calling pmu_layer__mkdir_p(), open(), and close() inside
export_builtin_pe_to_dir() and export_builtin_pm_to_dir() repeats a full
path walk and open/close on every event and metric during --export-cpuid
all.
[ ... ]
> + gdesc = pmu_metrics_table__describe_metricgroup(table, gbuf);
> + if (!gdesc)
> + gdesc = pmu_metrics_table__describe_metricgroup(
> + pmu_metrics_table__default(), gbuf);
> + ret = pmu_layer__export_metricgroup(ctx->target_root,
> + gbuf, gdesc);
[Severity: Low]
Should export_metric_groups_for_pm() deduplicate visited metricgroups per
model like export_dir_print_metric() does?
Because many metrics in a model share the same MetricGroup names, this
re-runs the description lookup and truncates and rewrites the same .desc
file on every referencing metric.
[ ... ]
> + if (ctx->opts->metricgroups) {
> + ret = export_metric_groups_for_pm(ctx, table, pm);
> + if (ret)
> + return ret;
> + }
> + if (!ctx->opts->metrics)
> + return 0;
> +
> + ret = export_builtin_pm_to_dir(ctx->target_root, pm);
> + if (ret)
> + return ret;
> + return record_sys_compat(ctx, pm->compat);
[Severity: Low]
Does the early return on !ctx->opts->metrics skip creating the
sys/<compat> symlink on a metricgroup-only export?
When running --export-cpuid <sys-selector> metricgroup,
export_metric_groups_for_pm() can write metricgroup descriptions under
models/<arch>/<model>/metricgroups/, but returning before
record_sys_compat() leaves them without a sys/<compat> symlink. Calling
record_sys_compat() before the !ctx->opts->metrics check is safe even when
nothing was written because ensure_rel_symlink() checks stat(target_dir)
first.
[ ... ]
> + if (!strcmp(arch, selector) ||
> + (!strcmp(selector, "test") && !strcmp(arch, "testarch")))
> + return true;
> + if (!strcmp(arch, "common"))
> + return !strcmp(selector, "common/common");
> +
> + snprintf(full_model, sizeof(full_model), "%s/%s", arch, model);
> + return strglobmatch(full_model, selector) || strglobmatch(model, selector);
[Severity: Low]
Why does arch_or_model_matches() alias exact "test" to "testarch" without
also matching "test/<model>" or "test/*" globs?
Because full_model is formatted with the raw "testarch" name, selectors
like --export-cpuid test/test_soc/cpu or test/* return -ENOENT even though
--export-cpuid test succeeds.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204011029.1946921-1-irogers@google.com?part=10
next prev parent reply other threads:[~2026-12-04 1:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 1:10 [PATCH v3 00/11] perf pmu: Layered sysfs-style PMU event and metric directories Ian Rogers
2026-12-04 1:10 ` [PATCH v3 01/11] perf pmu: Generalize pmu_alias_info_file() and lazy single-event sysfs loading Ian Rogers
2026-12-04 1:32 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 02/11] perf pmu: Add metric and metricgroup storage on struct perf_pmu Ian Rogers
2026-12-04 1:26 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 03/11] perf pmu-layer: Introduce stateless struct pmu_layer abstraction and builtin adapter Ian Rogers
2026-12-04 1:35 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 04/11] perf pmu-layer: Add openat-based directory layer with literal CPUID/symlink lookup Ian Rogers
2026-12-04 1:35 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 05/11] perf config: Add pmu-events.dir configuration option Ian Rogers
2026-12-04 1:27 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 06/11] perf pmu: Switch alias resolution and enumeration to layered PMU stack Ian Rogers
2026-12-04 1:38 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 07/11] perf metricgroup: Route metric and metricgroup lookups through struct perf_pmu Ian Rogers
2026-12-04 1:40 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 08/11] perf list, jevents: Add --export-dir and --output-dir sysfs-style exporters Ian Rogers
2026-12-04 1:36 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 09/11] perf jevents: Add compiled-in model and sys table iterators Ian Rogers
2026-12-04 1:10 ` [PATCH v3 10/11] perf list: Add --export-cpuid to export compiled-in CPU models Ian Rogers
2026-12-04 1:44 ` sashiko-bot [this message]
2026-12-04 1:10 ` [PATCH v3 11/11] perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overlay tests Ian Rogers
2026-12-04 1:49 ` sashiko-bot
2026-12-04 1:49 ` [PATCH v3 00/11] perf pmu: Layered sysfs-style PMU event and metric directories 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-248910@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.