On Friday, February 15, 2019 9:50 AM, Like Xu wrote: > To: Wang, Wei W <wei.w.wang@xxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; > kvm@xxxxxxxxxxxxxxx; pbonzini@xxxxxxxxxx; ak@xxxxxxxxxxxxxxx; > peterz@xxxxxxxxxxxxx > Cc: Liang, Kan <kan.liang@xxxxxxxxx>; mingo@xxxxxxxxxx; > rkrcmar@xxxxxxxxxx; Xu, Like <like.xu@xxxxxxxxx>; jannh@xxxxxxxxxx; > arei.gonglei@xxxxxxxxxx; jmattson@xxxxxxxxxx > Subject: Re: [PATCH v5 10/12] KVM/x86/lbr: lazy save the guest lbr stack > > On 2019/2/14 17:06, Wei Wang wrote: > > When the vCPU is scheduled in: > > - if the lbr feature was used in the last vCPU time slice, set the lbr > > stack to be interceptible, so that the host can capture whether the > > lbr feature will be used in this time slice; > > - if the lbr feature wasn't used in the last vCPU time slice, disable > > the vCPU support of the guest lbr switching. > > > > Upon the first access to one of the lbr related MSRs (since the vCPU > > was scheduled in): > > - record that the guest has used the lbr; > > - create a host perf event to help save/restore the guest lbr stack; > > Based on commit "15ad71460" and guest-use-lbr-only usage, is this possible > to create none of host perf event for vcpu and simply reuse > __intel_pmu_lbr_save/restore in intel_pmu_sched_out/in and keep the > lbr_stack sync with kvm_pmu->lbr_stack rather than task_ctx of perf_event ? Yes, both method should work. People may have different opinions about kvm or perf to own the job of lbr switching. Let's see.. if most people vote for kvm to do the switching, I'll make that change. Otherwise, I'll stay with what we already have. Best, Wei