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 10:45:43 +0000 [thread overview]
Message-ID: <20260206104543.GE3529712@e132581.arm.com> (raw)
In-Reply-To: <20260205183603.459363-2-irogers@google.com>
On Thu, Feb 05, 2026 at 10:36:03AM -0800, Ian Rogers wrote:
> The failure to find a table of metrics with a CPUID shouldn't early
> exit as the metric code will now also consider the default table.
> When searching for a metric or metric group,
> pmu_metrics_table__for_each_metric considers all tables and so the
> caller doesn't need to switch the table to do this.
>
> Fixes: c7adeb0974f1 ("perf jevents: Add set of common metrics based on default ones")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/metricgroup.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 40a1e14de418..46bf4dfeebc8 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -1562,8 +1562,6 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,
> {
> const struct pmu_metrics_table *table = pmu_metrics_table__find();
>
> - if (!table)
> - return -EINVAL;
> if (hardware_aware_grouping)
> pr_debug("Use hardware aware grouping instead of traditional metric grouping method\n");
>
> @@ -1601,22 +1599,16 @@ static int metricgroup__has_metric_or_groups_callback(const struct pmu_metric *p
>
> 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();
With this change, the default metrics can work on my side:
Performance counter stats for 'sleep 1':
1 context-switches # 434.8 cs/sec cs_per_second
0 cpu-migrations # 0.0 migrations/sec migrations_per_second
70 page-faults # 30439.1 faults/sec page_faults_per_second
2.30 msec task-clock # 0.0 CPUs CPUs_utilized
17398 armv8_pmuv3_0/branch-misses/ # 4.3 % branch_miss_rate
401746 armv8_pmuv3_0/branches/ # 174.7 M/sec branch_frequency
1778245 armv8_pmuv3_0/cpu-cycles/ # 0.8 GHz cycles_frequency
2341698 armv8_pmuv3_0/instructions/ # 1.3 instructions insn_per_cycle
680491 armv8_pmuv3_0/stalled-cycles-frontend/ # 0.38 frontend_cycles_idle
380360 armv8_pmuv3_0/stalled-cycles-backend/ # 0.21 backend_cycles_idle
380360 armv8_pmuv3_0/stalled-cycles-backend/ # 0.29 stalled_cycles_per_instruction
With above change:
Tested-by: Leo Yan <leo.yan@arm.com>
> struct metricgroup__has_metric_data data = {
> .pmu = pmu,
> .metric_or_groups = metric_or_groups,
> };
>
> - for (size_t i = 0; i < ARRAY_SIZE(tables); i++) {
> - if (pmu_metrics_table__for_each_metric(tables[i],
> - metricgroup__has_metric_or_groups_callback,
> - &data))
> - return true;
> - }
> - return false;
> + return pmu_metrics_table__for_each_metric(table,
> + metricgroup__has_metric_or_groups_callback,
> + &data)
> + ? true : false;
> }
>
> static int metricgroup__topdown_max_level_callback(const struct pmu_metric *pm,
> --
> 2.53.0.rc2.204.g2597b5adb4-goog
>
>
next prev parent reply other threads:[~2026-02-06 10:45 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 [this message]
2026-02-06 12:33 ` Leo Yan
2026-02-06 18:57 ` Ian Rogers
2026-02-06 21:50 ` Leo Yan
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=20260206104543.GE3529712@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