public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH] kvm: better MWAIT emulation for guests
Date: Wed, 15 Mar 2017 20:29:23 +0200	[thread overview]
Message-ID: <20170315202049-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170315181425.GA2239@HEDWIG.INI.CMU.EDU>

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 patch applied.
> 
> Single-(V)CPU guest works as expected (but then again, single-vcpu
> guests worked even back when I tried emulating MWAIT the same as HLT).
> 
> When I try starting a SMP guest (with "-smp 4,cores=2"), the guest OS
> hangs after generating some output in text/verbose boot mode -- I gave
> up waiting for it after about 5 minutes. Works fine before your patch,
> which leads me to suspect that, as I feared, MWAIT doesn't wake
> immediately upon another VCPU writing to the MONITOR-ed memory location.
> 
> Tangentially, I remember back in the days of OS X 10.7, the
> alternative to exiting guest mode and emulating MWAIT and MONITOR as
> NOPs was to allow them both to run in guest mode.
> 
> While poorly documented by Intel at the time, MWAIT at L>0 effectively
> behaves as a NOP (i.e., doesn't actually put the physical core into
> low-power mode, because doing that would allow a guest to effectively
> DOS the host hardware).

Thanks for the testing, interesting.
Testing with Linux guest seems to show it works.
This could be an interrupt thing not a monitor thing.
Question: does your host CPU have this in its MWAIT leaf?
	Bit 01: Supports treating interrupts as break-event for MWAIT, even when interrupts disabled

We really should check that before enabling,
I'll add that.

> 
> Given how unusual it is for a guest to use MONITOR/MWAIT in the first
> place, what's wrong with leaving it all as is (i.e., emulated as NOP)?
> 
> Thanks,
> --Gabriel

I'm really looking into ways to use mwait within Linux guests,
this is just a building block that should help Mac OSX
as a side effect (and we do not want it broken if at all possible).

-- 
MST

  reply	other threads:[~2017-03-15 18:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09 22:29 [PATCH] kvm: better MWAIT emulation for guests Michael S. Tsirkin
2017-03-10  0:51 ` Gabriel L. Somlo
2017-03-10  1:12   ` Michael S. Tsirkin
2017-03-13  7:44     ` Wanpeng Li
2017-03-10 23:46 ` Jim Mattson
2017-03-12  0:01   ` Michael S. Tsirkin
2017-03-12 21:18     ` Gabriel L. Somlo
2017-03-13 15:46 ` Radim Krčmář
2017-03-13 16:08   ` Michael S. Tsirkin
2017-03-13 19:39     ` Radim Krčmář
2017-03-13 20:03       ` Michael S. Tsirkin
2017-03-13 21:43         ` Radim Krčmář
2017-03-15 18:14           ` Gabriel L. Somlo
2017-03-15 18:29             ` Michael S. Tsirkin [this message]
2017-03-15 19:01               ` Gabriel L. Somlo
2017-03-15 19:05                 ` Michael S. Tsirkin
2017-03-15 19:29                 ` Michael S. Tsirkin
2017-03-15 19:43                   ` Gabriel L. Somlo
2017-03-15 20:13                     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170315202049-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=corbet@lwn.net \
    --cc=gsomlo@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox