Re: [PATCH v2] perf pmu: Skip test on Arm64 when #slots is zero

Leo Yan <[email protected]>
Newsgroups dev.linux.lists.sashiko,org.kernel.vger.linux-perf-users
Message-ID <[email protected]>
On Fri, Apr 10, 2026 at 11:28:23AM +0000, [email protected] wrote:

[...]

> > +static bool is_expected_broken_metric(const struct pmu_metric *pm)
> > +{
> > +	if (!strcmp(pm->metric_name, "M1") || !strcmp(pm->metric_name, "M2") ||
> > +	    !strcmp(pm->metric_name, "M3"))
> > +		return true;
> > +
> > +#if defined(__aarch64__)
> > +	/*
> > +	 * Arm64 platforms may return "#slots == 0", which is treated as a
> > +	 * syntax error by the parser. Don't test these metrics when running
> > +	 * on such platforms.
> > +	 */
> > +	if (strstr(pm->metric_expr, "#slots") &&
> > +	    !tool_pmu__cpu_slots_per_cycle())
> 
> Does reading host capabilities via tool_pmu__cpu_slots_per_cycle() bypass
> the fake PMU abstraction used by these tests?
> 
> The fake PMU tests are intended to validate the metric parser across all
> architectures without requiring the actual referenced PMUs or hardware
> capabilities to exist on the host machine.
> 
> Because tool_pmu__cpu_slots_per_cycle() checks the host's
> /sys/bus/event_source/devices/ caps/slots, does this break the test's
> hardware-independent validation?

I agreed that the test is designed for hardware-independent, however,
the low level's parser has already invoked
tool_pmu__cpu_slots_per_cycle() for event parsing, even with the fake
PMU.

[...]

> > @@ -852,8 +873,7 @@ static int test__parsing_callback(const struct pmu_metric *pm,
> >  
> >  	err = metricgroup__parse_groups_test(evlist, table, pm->metric_name);
> >  	if (err) {
> > -		if (!strcmp(pm->metric_name, "M1") || !strcmp(pm->metric_name, "M2") ||
> > -		    !strcmp(pm->metric_name, "M3")) {
> > +		if (is_expected_broken_metric(pm)) {
> >  			(*failures)--;
> >  			pr_debug("Expected broken metric %s skipping\n", pm->metric_name);
> >  			err = 0;
> 
> Does unconditionally clearing the error here create a testing blind spot
> for genuine syntax errors?
> 
> If a metric expression contains "#slots" on an Arm64 host without slot
> support, the failure is ignored entirely. Could this silently hide other
> issues, like typos in other events or malformed operators within the same
> metric expression?

The test will run on PMUs that support #slots, so any malformed metric
expressions can be detected.  Simply say, if a metric is applicable to
a platform, it will be verified on that platform.

I don't think I need any update on this patch.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.