Re: [PATCH v6 0/3] arm64: Add BRBE support for bpf_get_branch_snapshot()
From: Leo Yan
Date: Fri Nov 27 2026 - 06:11:40 EST
On Fri, Nov 27, 2026 at 10:56:27AM +0000, James Clark wrote:
> > Could we restrict bpf_get_branch_snapshot() on arm64 to a free-running
> > BRBE mode? On a given CPU, at least one active event would have to
> > request a branch stack, and every such event would have to be a
> > counting event.
> Yeah I think this is a pretty good idea. It looks like it would avoid having
> to disable NMIs. You only need a local_irq_save() to avoid new events from
> reconfiguring BRBE while taking a snapshot, and you don't have to disable
> the PMU counters either.
I'd like to avoid local_irq_save() if we can protect BRBE snapshot
reentry in another way.
> If any sampling BRBE event gets scheduled then the snapshots just start
> skipping and returning empty.
BPF program can be attached to interrupt handlers (even it can be
attached to PMU interrupt handler). As you suggested, we can use per-CPU
flag to return an empty snapshot for the nested call.
Thanks,
Leo