Re: [PATCH] perf test: Fix test case 120 and 121 for s390
From: Ian Rogers
Date: Mon Mar 09 2026 - 14:21:11 EST
On Mon, Mar 9, 2026 at 5:59 AM Thomas Richter <tmricht@xxxxxxxxxxxxx> wrote:
>
> On 3/6/26 17:53, Ian Rogers wrote:
> > On Fri, Mar 6, 2026 at 7:52 AM Jan Polensky <japo@xxxxxxxxxxxxx> wrote:
> >>
> >> On Fri, Mar 06, 2026 at 08:10:02AM +0100, Thomas Richter wrote:
> >>> Perf tests
> >>> 120: 'perf data convert --to-ctf' command test
> >>> 121: 'perf data convert --to-json' command test
> >>> fail on s390. It is caused by selecting the default event cycles
> >>> which does not exist on s390 z/VM. Use software event cpu-clock
> >>> and specify it explicitly on the command line.
> >>>
> >>> Output before:
> >>> ❯ perf test 120 121
> >>> 120: 'perf data convert --to-ctf' command test : FAILED!
> >>> 121: 'perf data convert --to-json' command test : FAILED!
> >>>
> >>> Output after:
> >>> ❯ perf test 120 121
> >>> 120: 'perf data convert --to-ctf' command test : Ok
> >>> 121: 'perf data convert --to-json' command test : Ok
> >>>
> >>> Signed-off-by: Thomas Richter <tmricht@xxxxxxxxxxxxx>
> >> [snip]
> >> Thanks for providing this, Thomas!
> >> Tested-by: Jan Polensky <japo@xxxxxxxxxxxxx>
> >> Reviewed-by: Jan Polensky <japo@xxxxxxxxxxxxx>
> >
> > Should we not fallback for the cycles as a default event?
> > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/builtin-record.c#n1374
> > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/evsel.c#n3792
> >
> > Thanks,
> > Ian
> >
>
> The fallback should be cpu-clock in case hardware event cycles (or CPU_CYCLES on s390) does not exist.
Thanks Thomas, so the change is doing:
```
- if ! perf record -o "$perfdata" -F 99 -g -- perf test -w noploop
+ if ! perf record -o "$perfdata" -e cpu-clock -F 99 -g -- perf
test -w noploop
```
where the default event is cycles:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/evlist.c#n116
Given that cycles will fail but then fallback to cpu-clock:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/evsel.c#n3792
I wonder if the issue is that the fallback is broken. Specifically:
```
evsel->core.attr.type == PERF_TYPE_HARDWARE &&
evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES) {
```
It isn't going to work well on hybrid machines or those whose PMU's
sysfs events or JSON include a cycles event. I wonder if using
`evsel__match(evsel, HARDWARE, CYCLES)` would be better, as the
evsel__match code is more robust to these kind of variances. I don't
know if that will address the fallback problem for you.
Thanks,
Ian
> Thanks Thomas
> --
> Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> --
> IBM Deutschland Research & Development GmbH
>
> Vorsitzender des Aufsichtsrats: Wolfgang Wendt
>
> Geschäftsführung: David Faller
>
> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294