From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796348672; b=pQHlkfvCm66eJ65XG9PU/+Na9qwQj0vo4cqNsR1hA65WGDNAixsUZdkVsUC07LwYhe9O gKTJQ6uqEkDnu5g0cbxgBhrm8AIqxf8fkEe6HSDOXhyZuyL3tSI3nXAVvfNouuUVATXpm D/7DqBY0tFcu3VcrXwjTaT1FXpT2IWL+xfA112bkUEM92MLUaj+PR266WBmG5lGsejLWp 8eoQiwdf1EZv6zsM42RMW9uR0P1WyEQir0rTwPxho890N3jiqtiXrJhrEFqFqSZC1bxaR OrmMO+FjpPINJGV+Z0FBPcAuxhDLFrpiqo6HUjeYFq51Nc/q7A1aN/jeuxQbIFSIs8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796348672; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Vr228dKxfVXRUsVkyGitkQe4AuzJAB7gF/Ygjo6OBV0=; b=nSPPuANDDZNCE4PBWmIfrcDgjkamy2q4IGgb1Je99jUd8N+GcFk4L8/5sPIO5axP4K7O 3jqNdIYUQkL2OIjywA0zYn7kCs69bSDLc0xaQcCPeVRVb4efc3RquschQz2g3X53FJEz1 7H0gKxljSMEriA3yGTEAx3YmzYL67iuLfwVzh2AQd7K2pXAUvj/Er1PM3rUNnxZoDXs+K f0Y21BbRCZGqc6/fTjrxUFleVCPVbp4gkYc+YtESsqAeJlfw3/h9tKocL5eGrd53SiWIh 2FA/Hs3W2DyKKWhzJW/bAAbvUMZqX139e7ICvOiWgNDQIuuKaczeB5Y9/xBErpLsQfw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pq9rjL9S; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFAB8606A322 for ; Fri, 4 Dec 2026 01:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Pq9rjL9S Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7963B1F000CE; Fri, 4 Dec 2026 01:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796348672; bh=Vr228dKxfVXRUsVkyGitkQe4AuzJAB7gF/Ygjo6OBV0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Pq9rjL9SgHry5/E3zhXdzxCUinMvvcv8CX1VdJVMlbSCkN2hiJtzXuFPr8Q3LCp3e nosWwY0U1ut7tMH9676nqXdQjB+p3QNaRkejaNuVpU+kSfjfkSNJUt6/4L59My3rhN 2QkPJGgdqa48r3gFXsYr23i833Dq28UL9OA0u3rDjqJ2JBLGDJtIgY08dcU5v6iaGr RUJoZ8Qn0DgN76IxqZaNz4obPZFwoEosoJnO0wPWilRP/2kda8JPF2PgoeY2bHUgvw n3+5NaGZIy6O2924m0FVoXAEQz7ekK71mkECUCgLEaIg+wdZvT7lqmBBNivY6RDF9m KG6S8pG5Cc2Jw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 10/11] perf list: Add --export-cpuid to export compiled-in CPU models Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261204011029.1946921-11-irogers@google.com> References: <20261204011029.1946921-1-irogers@google.com> <20261204011029.1946921-11-irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 01:44:32 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 =3D unit_name; > + } else if (cputype) { > + const struct perf_pmu *pmu =3D perf_pmus__pmu_for_pmu_filter(cputype); > + > + if (pmu) > + base_pmu_glob =3D 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 =3D "cpu_core"; > + else if (!strcasecmp(cputype, "atom")) > + base_pmu_glob =3D "cpu_atom"; [Severity: Low] Should builtin-list.c include for strcasecmp()? The file includes but not the POSIX-specified 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 =3D pmu_layer__mkdir_p(dir_path); > + if (ret =3D=3D 0) { > + fd =3D open(dir_path, O_RDONLY | O_DIRECTORY); > + if (fd < 0) { > + ret =3D -errno; > + } else { > + ret =3D 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 =3D pmu_layer__mkdir_p(dir_path); > + if (ret < 0) > + return ret; > + > + fd =3D open(dir_path, O_RDONLY | O_DIRECTORY); > + if (fd < 0) > + return -errno; > =20 > + ret =3D 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 =3D pmu_metrics_table__describe_metricgroup(table, gbuf); > + if (!gdesc) > + gdesc =3D pmu_metrics_table__describe_metricgroup( > + pmu_metrics_table__default(), gbuf); > + ret =3D 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 =3D export_metric_groups_for_pm(ctx, table, pm); > + if (ret) > + return ret; > + } > + if (!ctx->opts->metrics) > + return 0; > + > + ret =3D 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/ symlink on a metricgroup-only export? When running --export-cpuid metricgroup, export_metric_groups_for_pm() can write metricgroup descriptions under models///metricgroups/, but returning before record_sys_compat() leaves them without a sys/ 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, select= or); [Severity: Low] Why does arch_or_model_matches() alias exact "test" to "testarch" without also matching "test/" 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204011029.1946= 921-1-irogers@google.com?part=3D10