Re: [PATCH v5] arm64: pmuv3: dynamically map PERF_COUNT_HW_BRANCH_INSTRUCTIONS

From: Will Deacon
Date: Thu Apr 06 2023 - 11:11:10 EST


Hi Peter,

On Mon, Apr 03, 2023 at 11:15:47AM +0200, Peter Newman wrote:
> From: Stephane Eranian <eranian@xxxxxxxxxx>
>
> The mapping of perf_events generic hardware events to actual PMU events on
> ARM PMUv3 may not always be correct. This is in particular true for the
> PERF_COUNT_HW_BRANCH_INSTRUCTIONS event. Although the mapping points to an
> architected event, it may not always be available. This can be seen with a
> simple:
>
> $ perf stat -e branches sleep 0
> Performance counter stats for 'sleep 0':
>
> <not supported> branches
>
> 0.001401081 seconds time elapsed
>
> Yet the hardware does have an event that could be used for branches.
>
> Dynamically check for a supported hardware event which can be used for
> PERF_COUNT_HW_BRANCH_INSTRUCTIONS at mapping time.
>
> And with that:
>
> $ perf stat -e branches sleep 0
>
> Performance counter stats for 'sleep 0':
>
> 166,739 branches
>
> 0.000832163 seconds time elapsed
>
> Co-Developed-by: Stephane Eranian <eranian@xxxxxxxxxx>
> Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
> Co-Developed-by: Mark Rutland <mark.rutland@xxxxxxx>
> Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> Co-Developed-by: Peter Newman <peternewman@xxxxxxxxxx>
> Signed-off-by: Peter Newman <peternewman@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/YvunKCJHSXKz%2FkZB@FVFF77S0Q05N
> ---
> v4->v5:
> - update changelog tags

Thanks, this looks good to me.

Please can you rebase it on my for-next/perf branch so that I can queue it
up? More of the PMU code has moved out into drivers/perf/.

Cheers,

Will

[1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/log/?h=for-next/perf