[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190709093917.GS3402@hirez.programming.kicks-ass.net>
Date: Tue, 9 Jul 2019 11:39:17 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Wei Wang <wei.w.wang@...el.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
pbonzini@...hat.com, ak@...ux.intel.com, kan.liang@...el.com,
mingo@...hat.com, rkrcmar@...hat.com, like.xu@...el.com,
jannh@...gle.com, arei.gonglei@...wei.com, jmattson@...gle.com
Subject: Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host
save/restore the guest lbr stack
On Tue, Jul 09, 2019 at 11:04:21AM +0800, Wei Wang wrote:
> On 07/08/2019 10:48 PM, Peter Zijlstra wrote:
> > *WHY* does the host need to save/restore? Why not make VMENTER/VMEXIT do
> > this?
>
> Because the VMX transition is much more frequent than the vCPU switching.
> On SKL, saving 32 LBR entries could add 3000~4000 cycles overhead, this
> would be too large for the frequent VMX transitions.
>
> LBR state is saved when vCPU is scheduled out to ensure that this
> vCPU's LBR data doesn't get lost (as another vCPU or host thread that
> is scheduled in may use LBR)
But VMENTER/VMEXIT still have to enable/disable the LBR, right?
Otherwise the host will pollute LBR contents. And you then rely on this
'fake' event to ensure the host doesn't use LBR when the VCPU is
running.
But what about the counter scheduling rules; what happens when a CPU
event claims the LBR before the task event can claim it? CPU events have
precedence over task events.
Then your VCPU will clobber host state; which is BAD.
I'm missing all these details in the Changelogs. Please describe the
whole setup and explain why this approach.
Powered by blists - more mailing lists