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

Marc Zyngier maz at kernel.org
Mon Aug 14 23:32:40 PDT 2023


On Mon, 14 Aug 2023 08:16:27 +0100,
Leo Yan <leo.yan at linaro.org> wrote:
> 
> 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.

Maybe unclear to you, but rather clear to me (and most people else on
Cc).

> 
> In the example shared by Shijie in [1], the cycle counter is enabled
> for both host and guest

No. You're misreading the example. We're profiling the guest from the
host, and the guest has no PMU access.

> 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.

Who says that we're counting cycles using the cycle counter? This is
an event like any other, and it can be counted on any 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.

We have the root cause. You just need to think a bit harder.

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list