Re: [PATCH v6 0/3] arm64: Add BRBE support for bpf_get_branch_snapshot()

From: Leo Yan

Date: Thu Nov 26 2026 - 13:02:19 EST


On Thu, Nov 26, 2026 at 12:39:52PM +0000, James Clark wrote:

[...]

> > > > Mark, Will, you guys seems to be designated as maintainers for
> > > > drivers/perf/arm_brbe.c, can you please take a look and give your
> > > > feedback as well? This is important and useful feature for newer arm64
> > > > CPUs, it would be great to get access to this functionality that we
> > > > had on x86-64 side for a long while now. Please help get this upstream
> > > > or, if it's not in the right shape, guide Puranjay towards a better
> > > > implementation. Thank you!

...

> + Vladimir
>
> Hi Mark, Will, Vladimir,
>
> Any thoughts on this approach where NMIs need to be disabled? Alternatively
> we could do something like track where the PMU interrupts and BPF snapshots
> overlap and then discard the BRBE buffer and make sure they don't trample on
> each other etc, but it looks like it would be significantly more
> complicated.

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.

This seems to fit in this series. The selftest opens a CPU-cycles event
with PERF_SAMPLE_BRANCH_STACK and sample_period = 0, then takes the
snapshot from an fexit program.

Counting events can still generate overflow interrupts for bookkeeping.
It requires to refactor the PMU driver to leave BRBCR_ELx.FZP clear so
an overflow doesn't freeze BRBE. The interrupt handler could service the
counters without touching BRBE and losing the branch records.

Thanks,
Leo