RE: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wang, Wei W
On Sunday, October 14, 2018 8:41 PM, Wei Wang wrote: > Here is the plan I have in mind: > #1 Creates a host perf event on the guest's first bit-setting to > MSR_CORE_PERF_GLOBAL_CTRL; Meanwhile, disable the intercept of guest > access to this perf counter related MSRs (i.e. config_base and

RE: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wang, Wei W
On Sunday, October 14, 2018 8:41 PM, Wei Wang wrote: > Here is the plan I have in mind: > #1 Creates a host perf event on the guest's first bit-setting to > MSR_CORE_PERF_GLOBAL_CTRL; Meanwhile, disable the intercept of guest > access to this perf counter related MSRs (i.e. config_base and

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wei Wang
On 10/13/2018 09:30 PM, Peter Zijlstra wrote: On Fri, Oct 12, 2018 at 08:20:17PM +0800, Wei Wang wrote: Guest changing MSR_CORE_PERF_GLOBAL_CTRL causes KVM to reprogram pmc counters, which re-allocates a host perf event. This process is Yea gawds, that's horrific. Why does it do that? We have

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wei Wang
On 10/13/2018 09:30 PM, Peter Zijlstra wrote: On Fri, Oct 12, 2018 at 08:20:17PM +0800, Wei Wang wrote: Guest changing MSR_CORE_PERF_GLOBAL_CTRL causes KVM to reprogram pmc counters, which re-allocates a host perf event. This process is Yea gawds, that's horrific. Why does it do that? We have

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wei Wang
On 10/13/2018 04:09 PM, Paolo Bonzini wrote: It's not clear to me why you're special casing PMIs here. The optimization should work generically, right? Yeah, you can even just check if the counter is in the struct cpu_hw_events guest mask, and if so always write the counter MSR directly.

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-14 Thread Wei Wang
On 10/13/2018 04:09 PM, Paolo Bonzini wrote: It's not clear to me why you're special casing PMIs here. The optimization should work generically, right? Yeah, you can even just check if the counter is in the struct cpu_hw_events guest mask, and if so always write the counter MSR directly.

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-13 Thread Peter Zijlstra
On Fri, Oct 12, 2018 at 08:20:17PM +0800, Wei Wang wrote: > Guest changing MSR_CORE_PERF_GLOBAL_CTRL causes KVM to reprogram pmc > counters, which re-allocates a host perf event. This process is Yea gawds, that's horrific. Why does it do that? We have PERF_EVENT_IOC_PERIOD which does that much

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-13 Thread Peter Zijlstra
On Fri, Oct 12, 2018 at 08:20:17PM +0800, Wei Wang wrote: > Guest changing MSR_CORE_PERF_GLOBAL_CTRL causes KVM to reprogram pmc > counters, which re-allocates a host perf event. This process is Yea gawds, that's horrific. Why does it do that? We have PERF_EVENT_IOC_PERIOD which does that much

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-13 Thread Paolo Bonzini
On 12/10/2018 18:30, Andi Kleen wrote: >> 4. Results >> - Without this optimization, the guest pmi handling time is >> ~450 ns, and the max sampling rate is reduced to 250. >> - With this optimization, the guest pmi handling time is ~9000 ns >> (i.e. 1 / 500 of the

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-13 Thread Paolo Bonzini
On 12/10/2018 18:30, Andi Kleen wrote: >> 4. Results >> - Without this optimization, the guest pmi handling time is >> ~450 ns, and the max sampling rate is reduced to 250. >> - With this optimization, the guest pmi handling time is ~9000 ns >> (i.e. 1 / 500 of the

RE: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Wang, Wei W
On Saturday, October 13, 2018 12:31 AM, Andi Kleen wrote: > > 4. Results > > - Without this optimization, the guest pmi handling time is > > ~450 ns, and the max sampling rate is reduced to 250. > > - With this optimization, the guest pmi handling time is ~9000 ns > > (i.e.

RE: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Wang, Wei W
On Saturday, October 13, 2018 12:31 AM, Andi Kleen wrote: > > 4. Results > > - Without this optimization, the guest pmi handling time is > > ~450 ns, and the max sampling rate is reduced to 250. > > - With this optimization, the guest pmi handling time is ~9000 ns > > (i.e.

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Alexey Budankov
Hi, On 12.10.2018 19:30, Andi Kleen wrote: >> 4. Results >> - Without this optimization, the guest pmi handling time is >> ~450 ns, and the max sampling rate is reduced to 250. >> - With this optimization, the guest pmi handling time is ~9000 ns >> (i.e. 1 / 500 of the

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Alexey Budankov
Hi, On 12.10.2018 19:30, Andi Kleen wrote: >> 4. Results >> - Without this optimization, the guest pmi handling time is >> ~450 ns, and the max sampling rate is reduced to 250. >> - With this optimization, the guest pmi handling time is ~9000 ns >> (i.e. 1 / 500 of the

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Andi Kleen
> 4. Results > - Without this optimization, the guest pmi handling time is > ~450 ns, and the max sampling rate is reduced to 250. > - With this optimization, the guest pmi handling time is ~9000 ns > (i.e. 1 / 500 of the non-optimization case), and the max sampling >

Re: [PATCH v1] KVM/x86/vPMU: Guest PMI Optimization

2018-10-12 Thread Andi Kleen
> 4. Results > - Without this optimization, the guest pmi handling time is > ~450 ns, and the max sampling rate is reduced to 250. > - With this optimization, the guest pmi handling time is ~9000 ns > (i.e. 1 / 500 of the non-optimization case), and the max sampling >