Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-10 Thread Wei Wang
On 07/09/2019 07:45 PM, Peter Zijlstra wrote: +* config:Actually this field won't be used by the perf core +*as this event doesn't have a perf counter. +* sample_period: Same as above. If it's unused; why do we need to set it at all? OK, we'll

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-10 Thread Wei Wang
On 07/09/2019 08:19 PM, Peter Zijlstra wrote: For the lbr feature, could we thought of it as first come, first served? For example, if we have 2 host threads who want to use lbr at the same time, I think one of them would simply fail to use. So if guest first gets the lbr, host wouldn't take o

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-09 Thread Peter Zijlstra
On Tue, Jul 09, 2019 at 07:34:26PM +0800, Wei Wang wrote: > > But what about the counter scheduling rules; > > The counter is emulated independent of the lbr emulation. > > what happens when a CPU > > event claims the LBR before the task event can claim it? CPU events have > > precedence over ta

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-09 Thread Peter Zijlstra
On Mon, Jul 08, 2019 at 09:23:15AM +0800, Wei Wang wrote: > +int intel_pmu_enable_save_guest_lbr(struct kvm_vcpu *vcpu) > +{ > + struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); > + struct perf_event *event; > + > + /* > + * The main purpose of this perf event is to have the host perf core

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-09 Thread Wei Wang
On 07/09/2019 05:39 PM, Peter Zijlstra wrote: 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 sw

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-09 Thread Peter Zijlstra
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 en

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-08 Thread Wei Wang
On 07/08/2019 10:48 PM, Peter Zijlstra wrote: On Mon, Jul 08, 2019 at 09:23:15AM +0800, Wei Wang wrote: From: Like Xu This patch adds support to enable/disable the host side save/restore This patch should be disqualified on Changelog alone... Documentation/process/submitting-patches.rst:i

Re: [PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-08 Thread Peter Zijlstra
On Mon, Jul 08, 2019 at 09:23:15AM +0800, Wei Wang wrote: > From: Like Xu > > This patch adds support to enable/disable the host side save/restore This patch should be disqualified on Changelog alone... Documentation/process/submitting-patches.rst:instead of "[This patch] makes xyzzy do frot

[PATCH v7 08/12] KVM/x86/vPMU: Add APIs to support host save/restore the guest lbr stack

2019-07-07 Thread Wei Wang
From: Like Xu This patch adds support to enable/disable the host side save/restore for the guest lbr stack on vCPU switching. To enable that, the host creates a perf event for the vCPU, and the event attributes are set to the user callstack mode lbr so that all the conditions are meet in the host