[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <286AC319A985734F985F78AFA26841F73978F779@shsmsx102.ccr.corp.intel.com>
Date: Fri, 7 Sep 2018 15:21:32 +0000
From: "Wang, Wei W" <wei.w.wang@...el.com>
To: Jann Horn <jannh@...gle.com>
CC: kernel list <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
"Liang, Kan" <kan.liang@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Radim Kr?má? <rkrcmar@...hat.com>,
"Xu, Like" <like.xu@...el.com>
Subject: RE: [PATCH v2 7/8] KVM: PMU: support to save/restore the guest lbr
stack on vCPU switching
On Friday, September 7, 2018 10:37 PM, Jann Horn wrote:
> On Fri, Sep 7, 2018 at 4:28 PM Wei Wang <wei.w.wang@...el.com> wrote:
> > This patch adds support to KVM to save/restore the lbr stack on vCPU
> > context switching.
> >
> > When the guest sets the ACTIVE bit of MSR_KVM_PV_LBR_CTRL, a perf
> > event is created on the host for the related vCPU. This perf event
> > ensures the LBR stack to be saved/restored when the vCPU thread is
> scheduled out/in.
> > The perf event is removed and freed when the guest clears the ACTIVE
> > bit.
> [...]
> > +void guest_lbr_event_release(struct kvm_pmu *pmu) {
> > + struct perf_event *event = pmu->guest_lbr_event;
> > +
> > + if (unlikely(!pmu->guest_lbr_event)) {
> > + pr_err("%s: guest_lbr_event already freed\n", __func__);
> > + return;
> > + }
> > +
> > + if (event) {
> > + event->pmu->stop(event, PERF_EF_UPDATE);
> > + perf_event_release_kernel(event);
> > + }
> > + pmu->guest_lbr_event = NULL;
> > +}
>
> Is there some guarantee that this method will be called when the vCPU is
> torn down on guest exit?
Thanks for reminding us this corner case. We didn’t consider that in this version. I think we could add guest_lbr_event_release() to kvm_arch_vcpu_destroy()
Best,
Wei
Powered by blists - more mailing lists