Re: [PATCH v4 3/4] perf/arm64: Add BRBE support for bpf_get_branch_snapshot()
From: Rob Herring
Date: Fri Jun 05 2026 - 09:54:27 EST
On Wed, May 27, 2026 at 05:11:59AM -0700, Puranjay Mohan wrote:
> Enable bpf_get_branch_snapshot() on ARM64 by implementing the
> perf_snapshot_branch_stack static call for BRBE.
>
> BRBE is paused before masking exceptions to avoid branch buffer
> pollution from trace_hardirqs_off(). Exceptions are then masked with
> local_daif_save() to prevent PMU overflow pseudo-NMIs from interfering.
> If an overflow between pause and DAIF save re-enables BRBE, the snapshot
> detects this via BRBFCR_EL1.PAUSED and bails out.
>
> Branch records are read using perf_entry_from_brbe_regset() with a NULL
> event pointer to bypass event-specific filtering. The buffer is
> invalidated after reading.
>
> Introduce a for_each_brbe_entry() iterator to deduplicate bank
> iteration between brbe_read_filtered_entries() and the snapshot.
>
> Signed-off-by: Puranjay Mohan <puranjay@xxxxxxxxxx>
> ---
> drivers/perf/arm_brbe.c | 127 ++++++++++++++++++++++++++++++++-------
> drivers/perf/arm_brbe.h | 9 +++
> drivers/perf/arm_pmuv3.c | 5 +-
> 3 files changed, 119 insertions(+), 22 deletions(-)
Reviewed-by: Rob Herring (Arm) <robh@xxxxxxxxxx>