Re: [PATCH v7 bpf-next 1/3] perf: enable branch record for software events

From: Peter Zijlstra
Date: Fri Sep 10 2021 - 15:29:35 EST


On Fri, Sep 10, 2021 at 11:33:50AM -0700, Song Liu wrote:
> The typical way to access branch record (e.g. Intel LBR) is via hardware
> perf_event. For CPUs with FREEZE_LBRS_ON_PMI support, PMI could capture
> reliable LBR. On the other hand, LBR could also be useful in non-PMI
> scenario. For example, in kretprobe or bpf fexit program, LBR could
> provide a lot of information on what happened with the function. Add API
> to use branch record for software use.
>
> Note that, when the software event triggers, it is necessary to stop the
> branch record hardware asap. Therefore, static_call is used to remove some
> branch instructions in this process.
>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Acked-by: John Fastabend <john.fastabend@xxxxxxxxx>
> Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> Signed-off-by: Song Liu <songliubraving@xxxxxx>

Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>