Re: [PATCH] perf stat: Fix crash on arm64

From: Ian Rogers

Date: Mon Mar 23 2026 - 14:01:01 EST


On Wed, Mar 11, 2026 at 4:50 AM Leo Yan <leo.yan@xxxxxxx> wrote:
>
> Hi Breno,
>
> On Wed, Mar 11, 2026 at 03:21:00AM -0700, Breno Leitao wrote:
> > On Thu, Feb 05, 2026 at 10:22:27AM -0800, Ian Rogers wrote:
> > > I think it is a different issue, they have metrics while you don't.
> > > Your report does highlight we're missing a NO_JEVENTS=1 build-test,
> > > but the build is working for me. I'll send out two patches for these
> > > issues.
> >
> > Hi Ian, Leo, Acme
> >
> > I wanted to follow up on this. Are there any next steps I should take?
>
> Sorry for not tracking this issue.
>
> I can reproduce the issue on my Orion6 with setting a _dummy_ CPUID:
>
> $ export PERF_CPUID=0x00000000410fd490
> $ perf stat -C 5 -vvv
> ...
> Aborted
> perf: util/evsel.c:2156: get_group_fd: Assertion `!(!leader->core.fd)' failed
>
> Because we are working on different hardwares, I am a bit suspect I
> reproduced the issue with difference sequence as yours. Anyway, I do
> see that an event can be opened prior to its leader event, see the log
> below.
>
> Thus, your patch seems make sense to me as we need to ensure the leader
> event to be opened first. Ian, how about you think?

Because so many things depend on the event ordering, the patch makes
me very nervous, particularly how it will change architectural
requirement handling. Ordering the Intel slots and metric events is a
challenge. There is also how handling uncore events, which are
deliberately parsed out-of-order, will change. I've got a feeling the
test coverage for this isn't adequate, and finding the bugs requires
running on particular machines. It will also require examining the
default perf stat output to ensure this isn't broken; hopefully the
code is somewhat robust.

Ideally, the impact of the change on all these issues would be in the
commit message, but it's more realistic to cover each issue with
testing. I'll try to ask an AI buddy to help with this. Could you
rebase and send a v2? I'm curious to see what sashiko will throw up.

Thanks,
Ian

> I have a side question (maybe this is for James :): why other arch (or
> platforms) don't have reproduce the issue? I am wandering if any error
> or special stuffs in Arm CPU's json files.
>
> Thanks,
> Leo
>
>
> ---8<---
>
> Opening: BR_MIS_PRED
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x10 (br_mis_pred)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> disabled 1
> inherit 1
> ------------------------------------------------------------
> evsel=BR_MIS_PRED (supported=1) leader=BR_MIS_PRED
> sys_perf_event_open: pid -1 cpu 5 group_fd -1 flags 0x8
> sys_perf_event_open failed, error -2
> Warning:
> BR_MIS_PRED event is not supported by the kernel.
> The BR_MIS_PRED event is not supported.
> Opening: OP_SPEC
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x3b (op_spec)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> inherit 1
> ------------------------------------------------------------
> evsel=OP_SPEC (supported=1) leader=BR_MIS_PRED
> leader->core.fd=0xaaab19edd950
> broken group leader for OP_SPEC
> Warning:
> skipping event OP_SPEC that kernel failed to open.
> The sys_perf_event_open() syscall failed for event (OP_SPEC): Success
> "dmesg | grep -i perf" may provide additional information.
>
> Opening: STALL_SLOT
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x3f (stall_slot)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> inherit 1
> ------------------------------------------------------------
> evsel=STALL_SLOT (supported=1) leader=BR_MIS_PRED
> leader->core.fd=0xaaab19edd950
> broken group leader for STALL_SLOT
> Warning:
> skipping event STALL_SLOT that kernel failed to open.
> The sys_perf_event_open() syscall failed for event (STALL_SLOT): Success
> "dmesg | grep -i perf" may provide additional information.
>
> Opening: CPU_CYCLES
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x11 (cpu_cycles)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> inherit 1
> ------------------------------------------------------------
> evsel=CPU_CYCLES (supported=1) leader=BR_MIS_PRED
> leader->core.fd=0xaaab19edd950
> broken group leader for CPU_CYCLES
> Warning:
> skipping event CPU_CYCLES that kernel failed to open.
> The sys_perf_event_open() syscall failed for event (CPU_CYCLES): Success
> "dmesg | grep -i perf" may provide additional information.
>
> Opening: OP_RETIRED
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x3a (op_retired)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> inherit 1
> ------------------------------------------------------------
> evsel=OP_RETIRED (supported=1) leader=BR_MIS_PRED
> leader->core.fd=0xaaab19edd950
> broken group leader for OP_RETIRED
> Warning:
> skipping event OP_RETIRED that kernel failed to open.
> The sys_perf_event_open() syscall failed for event (OP_RETIRED): Success
> "dmesg | grep -i perf" may provide additional information.
>
> Opening: BR_MIS_PRED
> ------------------------------------------------------------
> perf_event_attr:
> type 11 (armv8_pmuv3_1)
> size 144
> config 0x10 (br_mis_pred)
> sample_type IDENTIFIER
> read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING|ID|GROUP
> inherit 1
> ------------------------------------------------------------
> evsel=BR_MIS_PRED (supported=1) leader=STALL_SLOT_BACKEND
> leader->core.fd=(nil)
> perf: util/evsel.c:2156: get_group_fd: Assertion `!(!leader->core.fd)' failed.