[PATCH] KVM: arm64: pmu: Resync EL0 state on counter rotation

Leo Yan leo.yan at linaro.org
Mon Aug 14 00:16:27 PDT 2023


On Fri, Aug 11, 2023 at 07:05:20PM +0100, Marc Zyngier wrote:
> Huang Shijie reports that, when profiling a guest from the host
> with a number of events that exceeds the number of available
> counters, the reported counts are wildly inaccurate. Without
> the counter oversubscription, the reported counts are correct.
> 
> Their investigation indicates that upon counter rotation (which
> takes place on the back of a timer interrupt), we fail to
> re-apply the guest EL0 enabling, leading to the counting of host
> events instead of guest events.

Seems to me, it's not clear for why the counter rotation will cause
the issue.

In the example shared by Shijie in [1], the cycle counter is enabled for
both host and guest, and cycle counter is a dedicated event which does
not share counter with other events.  Even there have counter rotation,
it should not impact the cycle counter.

I mean if we cannot explain clearly for this part, we don't find the
root cause, and this patch (and Shijie's patch) just walks around the
issue.

Thanks,
Leo

[1] https://lore.kernel.org/lkml/20230810072906.4007-1-shijie@os.amperecomputing.com/



More information about the linux-arm-kernel mailing list