Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:43:03PM -0400, Gabriel L. Somlo wrote: > Applies cleanly over git://git.kernel.org/pub/scm/virt/kvm/kvm.git, > but then I get: > > CC [M] arch/x86/kvm/x86.o > In file included from arch/x86/kvm/x86.c:28:0: > arch/x86/kvm/x86.h: In function ‘kvm_mwait_in_guest’: >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:43:03PM -0400, Gabriel L. Somlo wrote: > Applies cleanly over git://git.kernel.org/pub/scm/virt/kvm/kvm.git, > but then I get: > > CC [M] arch/x86/kvm/x86.o > In file included from arch/x86/kvm/x86.c:28:0: > arch/x86/kvm/x86.h: In function ‘kvm_mwait_in_guest’: >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
Applies cleanly over git://git.kernel.org/pub/scm/virt/kvm/kvm.git, but then I get: CC [M] arch/x86/kvm/x86.o In file included from arch/x86/kvm/x86.c:28:0: arch/x86/kvm/x86.h: In function ‘kvm_mwait_in_guest’: arch/x86/kvm/x86.h:231:34: error: ‘CPUID_MWAIT_LEAF’ undeclared (first use in this

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
Applies cleanly over git://git.kernel.org/pub/scm/virt/kvm/kvm.git, but then I get: CC [M] arch/x86/kvm/x86.o In file included from arch/x86/kvm/x86.c:28:0: arch/x86/kvm/x86.h: In function ‘kvm_mwait_in_guest’: arch/x86/kvm/x86.h:231:34: error: ‘CPUID_MWAIT_LEAF’ undeclared (first use in this

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:01:12PM -0400, Gabriel L. Somlo wrote: > On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > > Michael, > > > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:01:12PM -0400, Gabriel L. Somlo wrote: > On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > > Michael, > > > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:01:12PM -0400, Gabriel L. Somlo wrote: > On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > > Michael, > > > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 03:01:12PM -0400, Gabriel L. Somlo wrote: > On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > > Michael, > > > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > Michael, > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't check > > CPUID for MWAIT support. > > > > I used the latest kvm from

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
On Wed, Mar 15, 2017 at 08:29:23PM +0200, Michael S. Tsirkin wrote: > On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > > Michael, > > > > I tested this on OS X 10.7 (Lion), the last version that doesn't check > > CPUID for MWAIT support. > > > > I used the latest kvm from

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > Michael, > > I tested this on OS X 10.7 (Lion), the last version that doesn't check > CPUID for MWAIT support. > > I used the latest kvm from git://git.kernel.org/pub/scm/virt/kvm/kvm.git > first as-is, then with your v2 MWAIT

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Michael S. Tsirkin
On Wed, Mar 15, 2017 at 02:14:26PM -0400, Gabriel L. Somlo wrote: > Michael, > > I tested this on OS X 10.7 (Lion), the last version that doesn't check > CPUID for MWAIT support. > > I used the latest kvm from git://git.kernel.org/pub/scm/virt/kvm/kvm.git > first as-is, then with your v2 MWAIT

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
Michael, I tested this on OS X 10.7 (Lion), the last version that doesn't check CPUID for MWAIT support. I used the latest kvm from git://git.kernel.org/pub/scm/virt/kvm/kvm.git first as-is, then with your v2 MWAIT patch applied. Single-(V)CPU guest works as expected (but then again,

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-15 Thread Gabriel L. Somlo
Michael, I tested this on OS X 10.7 (Lion), the last version that doesn't check CPUID for MWAIT support. I used the latest kvm from git://git.kernel.org/pub/scm/virt/kvm/kvm.git first as-is, then with your v2 MWAIT patch applied. Single-(V)CPU guest works as expected (but then again,

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-13 22:03+0200, Michael S. Tsirkin: > On Mon, Mar 13, 2017 at 08:39:11PM +0100, Radim Krčmář wrote: > > 2017-03-13 18:08+0200, Michael S. Tsirkin: > > > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: >> >> What about keeping just the last hunk to improve OS X, for now? >> >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-13 22:03+0200, Michael S. Tsirkin: > On Mon, Mar 13, 2017 at 08:39:11PM +0100, Radim Krčmář wrote: > > 2017-03-13 18:08+0200, Michael S. Tsirkin: > > > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: >> >> What about keeping just the last hunk to improve OS X, for now? >> >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Michael S. Tsirkin
On Mon, Mar 13, 2017 at 08:39:11PM +0100, Radim Krčmář wrote: > 2017-03-13 18:08+0200, Michael S. Tsirkin: > > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: > >> 2017-03-10 00:29+0200, Michael S. Tsirkin: > >> > Some guests call mwait without checking the cpu flags. We currently >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Michael S. Tsirkin
On Mon, Mar 13, 2017 at 08:39:11PM +0100, Radim Krčmář wrote: > 2017-03-13 18:08+0200, Michael S. Tsirkin: > > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: > >> 2017-03-10 00:29+0200, Michael S. Tsirkin: > >> > Some guests call mwait without checking the cpu flags. We currently >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-13 18:08+0200, Michael S. Tsirkin: > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: >> 2017-03-10 00:29+0200, Michael S. Tsirkin: >> > Some guests call mwait without checking the cpu flags. We currently >> > emulate that as a NOP but on VMX we can do better: let guest stop

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-13 18:08+0200, Michael S. Tsirkin: > On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: >> 2017-03-10 00:29+0200, Michael S. Tsirkin: >> > Some guests call mwait without checking the cpu flags. We currently >> > emulate that as a NOP but on VMX we can do better: let guest stop

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Michael S. Tsirkin
On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: > 2017-03-10 00:29+0200, Michael S. Tsirkin: > > Some guests call mwait without checking the cpu flags. We currently > > emulate that as a NOP but on VMX we can do better: let guest stop the > > CPU until timer or IPI. CPU will be

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Michael S. Tsirkin
On Mon, Mar 13, 2017 at 04:46:20PM +0100, Radim Krčmář wrote: > 2017-03-10 00:29+0200, Michael S. Tsirkin: > > Some guests call mwait without checking the cpu flags. We currently > > emulate that as a NOP but on VMX we can do better: let guest stop the > > CPU until timer or IPI. CPU will be

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-10 00:29+0200, Michael S. Tsirkin: > Some guests call mwait without checking the cpu flags. We currently > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU until timer or IPI. CPU will be busy but that isn't any worse than > a NOP emulation. > > Note that

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Radim Krčmář
2017-03-10 00:29+0200, Michael S. Tsirkin: > Some guests call mwait without checking the cpu flags. We currently > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU until timer or IPI. CPU will be busy but that isn't any worse than > a NOP emulation. > > Note that

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Wanpeng Li
Cc Peterz, 2017-03-10 9:12 GMT+08:00 Michael S. Tsirkin : > On Thu, Mar 09, 2017 at 07:51:27PM -0500, Gabriel L. Somlo wrote: >> On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: >> > Some guests call mwait without checking the cpu flags. We currently >> >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-13 Thread Wanpeng Li
Cc Peterz, 2017-03-10 9:12 GMT+08:00 Michael S. Tsirkin : > On Thu, Mar 09, 2017 at 07:51:27PM -0500, Gabriel L. Somlo wrote: >> On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: >> > Some guests call mwait without checking the cpu flags. We currently >> > emulate that as a NOP

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-12 Thread Gabriel L. Somlo
On Sun, Mar 12, 2017 at 02:01:32AM +0200, Michael S. Tsirkin wrote: > On Fri, Mar 10, 2017 at 03:46:45PM -0800, Jim Mattson wrote: > > On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > > > Some guests call mwait without checking the cpu flags. We currently > > > >

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-12 Thread Gabriel L. Somlo
On Sun, Mar 12, 2017 at 02:01:32AM +0200, Michael S. Tsirkin wrote: > On Fri, Mar 10, 2017 at 03:46:45PM -0800, Jim Mattson wrote: > > On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > > > Some guests call mwait without checking the cpu flags. We currently > > > > "Some guests"? What

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-11 Thread Michael S. Tsirkin
On Fri, Mar 10, 2017 at 03:46:45PM -0800, Jim Mattson wrote: > On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > > Some guests call mwait without checking the cpu flags. We currently > > "Some guests"? What guests other than Mac OS X are so ill-behaved? I heard about

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-11 Thread Michael S. Tsirkin
On Fri, Mar 10, 2017 at 03:46:45PM -0800, Jim Mattson wrote: > On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > > Some guests call mwait without checking the cpu flags. We currently > > "Some guests"? What guests other than Mac OS X are so ill-behaved? I heard about Mac OSX only but

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-10 Thread Jim Mattson
On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > Some guests call mwait without checking the cpu flags. We currently "Some guests"? What guests other than Mac OS X are so ill-behaved? > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-10 Thread Jim Mattson
On Thu, Mar 9, 2017 at 2:29 PM, Michael S. Tsirkin wrote: > Some guests call mwait without checking the cpu flags. We currently "Some guests"? What guests other than Mac OS X are so ill-behaved? > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU until timer or IPI.

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Michael S. Tsirkin
On Thu, Mar 09, 2017 at 07:51:27PM -0500, Gabriel L. Somlo wrote: > On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: > > Some guests call mwait without checking the cpu flags. We currently > > emulate that as a NOP but on VMX we can do better: let guest stop the > > CPU until

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Michael S. Tsirkin
On Thu, Mar 09, 2017 at 07:51:27PM -0500, Gabriel L. Somlo wrote: > On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: > > Some guests call mwait without checking the cpu flags. We currently > > emulate that as a NOP but on VMX we can do better: let guest stop the > > CPU until

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Gabriel L. Somlo
On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: > Some guests call mwait without checking the cpu flags. We currently > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU until timer or IPI. CPU will be busy but that isn't any worse than > a NOP

Re: [PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Gabriel L. Somlo
On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote: > Some guests call mwait without checking the cpu flags. We currently > emulate that as a NOP but on VMX we can do better: let guest stop the > CPU until timer or IPI. CPU will be busy but that isn't any worse than > a NOP

[PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Michael S. Tsirkin
Some guests call mwait without checking the cpu flags. We currently emulate that as a NOP but on VMX we can do better: let guest stop the CPU until timer or IPI. CPU will be busy but that isn't any worse than a NOP emulation. Note that mwait within guests is not the same as on real hardware

[PATCH] kvm: better MWAIT emulation for guests

2017-03-09 Thread Michael S. Tsirkin
Some guests call mwait without checking the cpu flags. We currently emulate that as a NOP but on VMX we can do better: let guest stop the CPU until timer or IPI. CPU will be busy but that isn't any worse than a NOP emulation. Note that mwait within guests is not the same as on real hardware