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=1796347596; b=yQwwRRsutWQGP3w6cpk2laqsufS8T1jjNWhXbXLT6yxBJ6aMGHE7vKHTjkPHT1Uh7zWE se/SE7V0OnL5erdomf7Vpu3IKLkWHFZjbW4+lN3NPwBXty1syfAfewhHCQ3zagj+TcdDz LTRpH+OTCV39Z9jGx5Vco863v4ZJ2UhpriTZhcD6sjw6WAqaopQoycplyeeIgoQrdW62l +Nl9FP8Ckjradqy+PCN5KiKknqQncmeO/Uo7PStDORNcQEgogMnAc2wq4+FXUGy7OlbLs vYOvGtwfF99nKCpjj2jljpUeIZKACSDcw8h1uwI9BePBLxZ5a8YNjrfyWZgYopJW9nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796347596; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Rhje5EugujAZGBQt/LDUX5R3Ou5bKcPMZ+2ow85EGUo=; b=yxSTrf235V7En/39JIxPAtXRXPS3rERGDP5T+WTj3gGEHtnEDGVijvFpJjSP5SXQU0gY TrukYqlRdOTsOgV06NNV9M7oZPDuXAz1XcdlXjMXUkxC6A+o7LvbxRKEKllWXygn3BkpS axRAp5wf1a77BLbYN29KaLUot1DE5UaHwLMO4ciy3OtJtMxUPg9SnTKkNjTLsDFSrP1pk 8qwzCrB9n6xKr6LdeF8lP+44YhxQHZvAyTVegzcDspUDAEj9ig2Z8cvvktUKvCXB4Fr2q kstAubMOHx8/7BHfsbJFALF57qhf3JUYDDsIBi/t/mhhsOCxaPlliB+pe1sDbn4o3xg== 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=Fm9D2oAG; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6068606A322 for ; Fri, 4 Dec 2026 01:26:35 +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=Fm9D2oAG Received: by smtp.kernel.org (Postfix) with ESMTPSA id B33601F000CE; Fri, 4 Dec 2026 01:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347595; bh=Rhje5EugujAZGBQt/LDUX5R3Ou5bKcPMZ+2ow85EGUo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Fm9D2oAGj7CF1omYoZdxOJSbOmSvLzaEJJF8EUzY/iXxtUzqOGffiFhVPzJ6yUF6h L75Krs13s1BqOopDPPCYQK6qQW0I4Nsi/PqkrtgjepyOxlErp00mdY5uav3kHV3tCD +qZRBP9ZYWijQ5NBU4aBIY4MOYKAaXnXCTJSsCwXcQE4aC/niKUHIn7/fdrH513Rh6 GkqBl2BPtX5ST//+qJVlmW+x3X+HYb5KExaidrikQ1idwK6EIGyqLhfGG3XCG3tJY8 rYfB04A4lZwg2nOGUMNFxySE4YXD7M4Bh8c6FS8nKMwnRcUBCxjeWbcjQq8OQ4EdQv yNq0tAN2OTHKQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 02/11] perf pmu: Add metric and metricgroup storage on struct perf_pmu Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261204011029.1946921-3-irogers@google.com> References: <20261204011029.1946921-1-irogers@google.com> <20261204011029.1946921-3-irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 01:26:34 +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 3 potential issues to consider: - [Medium] perf pmu: uncached per-PMU regex scan in perf_pmu__lookup_metrics_table() - [Medium] perf pmu: wrong-core metrics fallback in perf_pmu__lookup_metrics_table() - [Medium] perf pmu: placeholder core PMU attaches JSON events without sysfs formats -- commit 5a14155933e78303fc11c12ec836f00df5969bd3 Author: Ian Rogers perf pmu: Add metric and metricgroup storage on struct perf_pmu This commit adds metric and metricgroup hashmaps and a metrics_table pointer to struct perf_pmu, populates them during PMU initialization and lookup, and frees them in perf_pmu__delete(). > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index c5ab6c6881990..261eaf75b01fe 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c [ ... ] > @@ -1354,6 +1562,33 @@ static bool aliases__equal(long key1, long key2, v= oid *ctx __maybe_unused) [ ... ] > +static const struct pmu_metrics_table *perf_pmu__lookup_metrics_table(st= ruct perf_pmu *pmu) > +{ > + const struct pmu_metrics_table *table =3D NULL; > + const char *arch =3D perf_env__arch(NULL); > + struct perf_cpu cpu =3D pmu ? perf_cpu_map__min(pmu->cpus) : (struct pe= rf_cpu){ -1 }; > + char *cpuid =3D get_cpuid_allow_env_override(cpu); > + > + if (cpuid) { > + if (arch) > + table =3D find_core_metrics_table(arch, cpuid); > + free(cpuid); > + } > + if (!table) > + table =3D pmu_metrics_table__find(); > + return table; > +} [Severity: Medium] Can the fallback to pmu_metrics_table__find() attach the wrong CPU's metrics table to an unrecognized heterogeneous core PMU? When find_core_metrics_table() returns NULL for a valid per-PMU CPUID, pmu_metrics_table__find() calls map_for_cpu() with cpu =3D -1. On arm64, get_cpuid() then returns CPU 0's MIDR, so an unrecognized core PMU inherits CPU 0's metrics table instead of NULL. [ ... ] > @@ -1443,6 +1692,7 @@ struct perf_pmu *perf_pmu__lookup(struct list_head = *pmus, int dirfd, const char > pmu->max_precise =3D pmu_max_precise(dirfd, pmu); > pmu->alias_name =3D pmu_find_alias_name(pmu, dirfd); > pmu->events_table =3D perf_pmu__find_events_table(pmu); > + pmu->metrics_table =3D perf_pmu__lookup_metrics_table(pmu); [Severity: Medium] Does calling perf_pmu__lookup_metrics_table() here regress PMU scan startup time? Unlike perf_pmu__find_events_table(), which uses map_for_pmu() and map_for_cpu()'s static caches, perf_pmu__lookup_metrics_table() re-fetches the CPUID and linearly scans pmu_events_map[] for every sysfs PMU in pmu_read_sysfs(). On x86, find_core_metrics_table() runs regcomp()/regexec() via strcmp_cpuid_str() per entry, adding thousands of regex compilations on large systems. A symmetric perf_pmu__find_metrics_table() helper backed by map_for_pmu() would reuse the cache. [ ... ] > @@ -1468,19 +1720,16 @@ struct perf_pmu *perf_pmu__create_placeholder_cor= e_pmu(struct list_head *core_pm > pmu->is_core =3D true; > - pmu->type =3D PERF_TYPE_RAW; > pmu->cpus =3D cpu_map__online(); > + pmu->events_table =3D perf_pmu__find_events_table(pmu); > + pmu->metrics_table =3D perf_pmu__lookup_metrics_table(pmu); [Severity: Medium] Should the placeholder core PMU populate pmu->events_table when pmu->format is empty? In environments without a sysfs core PMU (such as VMs), attaching the CPU JSON events table causes perf list to advertise non-legacy events on the placeholder cpu PMU, yet parsing any of them fails with -EINVAL in pmu_config_term() because pmu->format has no format terms. This also changes existing behavior without mentioning it in the commit message. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204011029.1946= 921-1-irogers@google.com?part=3D2