From: Leo Yan <leo.yan@arm.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] perf metricgroup: Don't early exit if no CPUID table exists
Date: Fri, 6 Feb 2026 21:50:01 +0000 [thread overview]
Message-ID: <20260206215001.GJ3529712@e132581.arm.com> (raw)
In-Reply-To: <CAP-5=fV8ofWn2oYDip3pOX7+Cx0GyKckq_o0Q6qahuoqgydN7w@mail.gmail.com>
On Fri, Feb 06, 2026 at 10:57:54AM -0800, Ian Rogers wrote:
[...]
> > > > bool metricgroup__has_metric_or_groups(const char *pmu, const char *metric_or_groups)
> > > > {
> > > > - const struct pmu_metrics_table *tables[2] = {
> > > > - pmu_metrics_table__find(),
> > > > - pmu_metrics_table__default(),
> > > > - };
> > > > + const struct pmu_metrics_table *table = pmu_metrics_table__find();
> > >
> > > Here should be:
> > >
> > > const struct pmu_metrics_table *table = pmu_metrics_table__default();
> >
> > Or, I think you should not change metricgroup__has_metric_or_groups().
> > The change only in metricgroup__parse_groups() can fix my issue.
>
> This is wrong and the patch I tested I believe to be correct.
It is very likely you are not working on the issue same as mine.
> The table here is CPUID associated table and all the metric code will
As you said, the key point is CPUID. On my board, as no corresponding
json file to support the CPU variant, it fails to find any table based
on the CPUID and pmu_metrics_table__find() always returns NULL.
The failure flow is:
add_default_events()
if (!metricgroup__has_metric_or_groups(pmu, default_metricgroup_names[i]))
continue;
^^^
Always return false
As a result, metricgroup__parse_groups() has no chance to be invoked
and no any events are added to the ev list.
This is why I suggested to keep default table in
metricgroup__has_metric_or_groups(), it can rallback to find default
table when CPUID is not supported.
> bottom out in metricgroup__for_each_metric where the CPUID table is
> the table parameter (its a parameter because of testing where we force
> the machine/model to "testarch"):
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/metricgroup.c?h=perf-tools-next#n430
> ```
> int metricgroup__for_each_metric(const struct pmu_metrics_table
> *table, pmu_metric_iter_fn fn, void *data)
> {
> ...
> const struct pmu_metrics_table *tables[2] = {
> table,
> pmu_metrics_table__default(),
> };
>
> for (size_t i = 0; i < ARRAY_SIZE(tables); i++) {
> int ret;
>
> if (!tables[i])
> continue;
> ```
> If you make the table here the default table then you will process the
> default table twice in metricgroup__for_each_metric which will mean
> double metric look ups, etc.
In my case, it will not have double metric issue, as
pmu_metrics_table__find() cannot find any table, a NULL table pointer
will be passed to metricgroup__for_each_metric(), then only
pmu_metrics_table__default() will be used.
As a side question, using a single CPUID to look up metrics can be
error-prone on asymmetric systems (such as Arm big.LITTLE). Since only
the first CPU ID is used to search the metrics table, could this cause
issues for other CPU variants?
Thanks,
Leo
next prev parent reply other threads:[~2026-02-06 21:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 18:36 [PATCH v1 1/2] perf tests: build-test coverage for NO_JEVENTS=1 Ian Rogers
2026-02-05 18:36 ` [PATCH v1 2/2] perf metricgroup: Don't early exit if no CPUID table exists Ian Rogers
2026-02-06 10:45 ` Leo Yan
2026-02-06 12:33 ` Leo Yan
2026-02-06 18:57 ` Ian Rogers
2026-02-06 21:50 ` Leo Yan [this message]
2026-02-06 22:16 ` Ian Rogers
2026-02-07 0:14 ` Ian Rogers
2026-02-07 0:49 ` [PATCH v1] perf metricgroup: Fix metricgroup__has_metric_or_groups Ian Rogers
2026-02-09 9:22 ` Leo Yan
2026-02-09 23:06 ` Ian Rogers
2026-02-10 9:11 ` Leo Yan
2026-02-24 17:57 ` Namhyung Kim
2026-02-06 8:53 ` [PATCH v1 1/2] perf tests: build-test coverage for NO_JEVENTS=1 Leo Yan
2026-02-06 14:57 ` Arnaldo Carvalho de Melo
2026-02-06 14:59 ` Arnaldo Carvalho de Melo
2026-02-06 16:09 ` Leo Yan
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=20260206215001.GJ3529712@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®