All of lore.kernel.org
 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 v3 25/30] perf pmus: Add perf_pmus__read_from_env()
Date: Fri, 20 Nov 2026 22:42:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-226290@kernel.org> (raw)
In-Reply-To: <20261120221332.2245191-26-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf pmus: env_pmu_find_or_add() misclassifies s390 cpum_sf
  as a core PMU
--

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

perf pmus: Add perf_pmus__read_from_env()

This commit adds perf_pmus__read_from_env() and perf_pmu__add_cap() to
reconstruct PMU lists and capabilities from perf.data header metadata and
lazily populate env->pmus in perf_env__pmus().

> diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c
> index 1c3cb53c3d4ff..c5ef22ef00dc0 100644
> --- a/tools/perf/util/pmus.c
> +++ b/tools/perf/util/pmus.c
[ ... ]
> @@ -1004,3 +1007,247 @@ struct perf_pmu *perf_pmus__fake_pmu(void)
[ ... ]
> +static struct perf_pmu *env_pmu_find_or_add(struct perf_pmus *pmus,
> +					    const char *name, __u32 type,
> +					    struct perf_env *env,
> +					    const struct pmu_events_table *core_table)
> +{
> +	struct perf_pmu *pmu = pmu_find(pmus, name);
> +
> +	if (type == PERF_PMU_TYPE_FAKE) {
> +		if (!strcmp(name, "software"))
> +			type = PERF_TYPE_SOFTWARE;
> +		else if (!strcmp(name, "tracepoint"))
> +			type = PERF_TYPE_TRACEPOINT;
> +		else if (!strcmp(name, "breakpoint"))
> +			type = PERF_TYPE_BREAKPOINT;
> +		else if (!strcmp(name, "tool"))
> +			type = PERF_PMU_TYPE_TOOL;
> +	}
> +
> +	if (pmu) {
> +		if (pmu->type == PERF_PMU_TYPE_FAKE && type != PERF_PMU_TYPE_FAKE) {
> +			pmu->type = type;
> +			if (!pmu->is_core && type == PERF_TYPE_RAW) {
> +				pmu->is_core = true;
> +				list_move_tail(&pmu->list, &pmus->core_pmus);
> +			}
> +			pmu->is_uncore = !pmu->is_core && !pmu->auxtrace &&
> +					 !perf_pmu__is_software(pmu) &&
> +					 perf_pmu__kind(pmu) == PERF_PMU_KIND_PE;
> +			if (!pmu->is_core && !pmu->is_uncore &&
> +			    pmu->events_table == core_table) {
> +				pmu->events_table = NULL;
> +			} else if (!pmu->events_table && (pmu->is_core || pmu->is_uncore) &&
> +				   pmu_events_table__num_events(core_table, pmu) > 0) {
> +				pmu->events_table = core_table;
> +			}
> +		}
> +		return pmu;
> +	}
> +
> +	pmu = zalloc(sizeof(*pmu));
> +	if (!pmu)
> +		return NULL;
> +
> +	if (perf_pmu__init(pmu, type, name, /*from_env=*/true) != 0) {
> +		perf_pmu__delete(pmu);
> +		return NULL;
> +	}
> +
> +	pmu->pmus = pmus;
> +	pmu->sysfs_aliases_loaded = true;
> +	pmu->caps_initialized = true;
> +	pmu->max_precise = -1;
> +	pmu->is_core = type == PERF_TYPE_RAW || env_is_pmu_core(name, env);

[Severity: Medium]
Does treating type == PERF_TYPE_RAW as a core PMU misclassify s390's cpum_sf
PMU?

On s390, cpum_cf is the core counter facility PMU (registered with a dynamic
type and matched by env_is_pmu_core()), while cpum_sf is the non-core
sampling facility PMU registered with PERF_TYPE_RAW (arch/s390/kernel/
perf_cpum_sf.c).  When reading HEADER_PMU_MAPPINGS from an s390 perf.data
file, marking any PERF_TYPE_RAW PMU as pmu->is_core puts both cpum_cf and
cpum_sf on pmus->core_pmus.  That makes perf_pmus__num_core_pmus() return 2
and perf_pmus__supports_extended_type() return true, causing s390 recordings
to be treated as hybrid systems.

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

  reply	other threads:[~2026-11-20 22:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 22:13 [PATCH v3 00/30] perf: Per-env PMUs, metric event sharing, and recorded event metrics Ian Rogers
2026-11-20 22:13 ` [PATCH v3 01/30] perf pmus: Don't skip core PMUs as duplicates Ian Rogers
2026-11-20 22:13 ` [PATCH v3 02/30] perf script: Fix metrics computed from samples Ian Rogers
2026-11-20 22:13 ` [PATCH v3 03/30] perf script: Don't drop metric samples for CPUs missing from the evsel Ian Rogers
2026-11-20 22:13 ` [PATCH v3 04/30] perf metricgroup: Don't prefer tool events for displaying a metric Ian Rogers
2026-11-20 22:13 ` [PATCH v3 05/30] perf env: Make lazy perf_env initialization thread-safe Ian Rogers
2026-11-20 22:13 ` [PATCH v3 06/30] perf env: Add host_env() singleton Ian Rogers
2026-11-20 22:13 ` [PATCH v3 07/30] perf pmu: Add from_env parameter to perf_pmu__init() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 08/30] perf pmus: Introduce struct perf_pmus and perf_env__pmus() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 09/30] perf pmus: Pass struct perf_pmus to find helpers Ian Rogers
2026-11-20 22:13 ` [PATCH v3 10/30] perf pmus: Pass struct perf_pmus to scan helpers Ian Rogers
2026-11-20 22:13 ` [PATCH v3 11/30] perf pmu-events: Add e_machine to struct pmu_events_map Ian Rogers
2026-11-20 22:13 ` [PATCH v3 12/30] perf pmu-events: Pass e_machine to find_core_*_table() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 13/30] perf header: Pass e_machine to strcmp_cpuid_str() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 14/30] perf header: Support CPUID matching across all architectures Ian Rogers
2026-11-20 22:13 ` [PATCH v3 15/30] perf test: Make the CPUID matching test architecture independent Ian Rogers
2026-11-20 22:13 ` [PATCH v3 16/30] perf test: Add CPUID matching tests for other architectures Ian Rogers
2026-11-20 22:13 ` [PATCH v3 17/30] perf dwarf-regs: Add e_machine__same_arch() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 18/30] perf metricgroup: Pass struct perf_pmus to metricgroup__for_each_metric() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 19/30] perf metricgroup: Move matching of metrics to recorded events from perf script Ian Rogers
2026-11-20 22:13 ` [PATCH v3 20/30] perf parse-events: Decode metric-id terms when adding events Ian Rogers
2026-11-20 22:13 ` [PATCH v3 21/30] perf evsel: Generalize metric_id to a set of metric_ids Ian Rogers
2026-11-20 22:13 ` [PATCH v3 22/30] perf pmu: Add perf_pmu__for_each_name_from_config() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 23/30] perf metricgroup: Share metric events by their counter encoding Ian Rogers
2026-11-20 22:13 ` [PATCH v3 24/30] perf stat: Share events between metrics and command line events Ian Rogers
2026-11-20 22:13 ` [PATCH v3 25/30] perf pmus: Add perf_pmus__read_from_env() Ian Rogers
2026-11-20 22:42   ` sashiko-bot [this message]
2026-11-20 22:13 ` [PATCH v3 26/30] perf metricgroup: Improve matching of metrics to recorded events Ian Rogers
2026-11-20 22:13 ` [PATCH v3 27/30] perf metricgroup: Add metricgroup__add_recorded_metrics() Ian Rogers
2026-11-20 22:13 ` [PATCH v3 28/30] perf stat report: Display metrics for recorded events Ian Rogers
2026-11-20 22:13 ` [PATCH v3 29/30] perf script: Display metrics for perf stat record data Ian Rogers
2026-11-20 22:13 ` [PATCH v3 30/30] perf test: Add stat record metrics test Ian Rogers
2026-11-20 22:42 ` [PATCH v3 00/30] perf: Per-env PMUs, metric event sharing, and recorded event metrics 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-226290@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.