Re: [RFC PATCH v2] perf: honouring the cpuid for number of fixed counters in hypervisors

From: Andi Kleen
Date: Mon Oct 24 2016 - 12:50:07 EST


On Fri, Oct 21, 2016 at 01:18:59AM -0700, Imre Palik wrote:
> From: Imre Palik <imrep@xxxxxxxxx>
>
> perf doesn't seem to honour the number of fixed counters specified by cpuid
> leaf 0xa. It always assume that Intel CPUs have at least 3 fixed counters.
>
> So if some of the fixed counters are masked out by the hypervisor, it still
> tries to check/set them.
>
> This patch makes perf behave nicer when the kernel is running under a
> hypervisor that doesn't expose all the counters.
>
> This patch contains some ideas from Matt Wilson.

Patch looks good to me.

Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

-Andi