Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751185AbdCOXl5 (ORCPT ); Wed, 15 Mar 2017 19:41:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58826 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108AbdCOXlc (ORCPT ); Wed, 15 Mar 2017 19:41:32 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CEC4DF6231 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CEC4DF6231 Date: Thu, 16 Mar 2017 01:41:28 +0200 From: "Michael S. Tsirkin" To: "Gabriel L. Somlo" Cc: linux-kernel@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Joerg Roedel , kvm@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v5 untested] kvm: better MWAIT emulation for guests Message-ID: <20170316013903-mutt-send-email-mst@kernel.org> References: <1489612895-12799-1-git-send-email-mst@redhat.com> <20170315233534.GG2239@HEDWIG.INI.CMU.EDU> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170315233534.GG2239@HEDWIG.INI.CMU.EDU> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 15 Mar 2017 23:41:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2464 Lines: 54 On Wed, Mar 15, 2017 at 07:35:34PM -0400, Gabriel L. Somlo wrote: > On Wed, Mar 15, 2017 at 11:22:18PM +0200, Michael S. Tsirkin wrote: > > Guests running Mac OS 5, 6, and 7 (Leopard through Lion) have a problem: > > unless explicitly provided with kernel command line argument > > "idlehalt=0" they'd implicitly assume MONITOR and MWAIT availability, > > without checking CPUID. > > > > We currently emulate that as a NOP but on VMX we can do better: let > > guest stop the CPU until timer, IPI or memory change. 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 > > because halt causes an exit while mwait doesn't. For this reason it > > might not be a good idea to use the regular MWAIT flag in CPUID to > > signal this capability. Add a flag in the hypervisor leaf instead. > > > > Additionally, we add a capability for QEMU - e.g. if it knows there's an > > isolated CPU dedicated for the VCPU it can set the standard MWAIT flag > > to improve guest behaviour. > > Same behavior (on the mac pro 1,1 running F22 with custom-compiled > kernel from kvm git master, plus this patch on top). > > The OS X 10.7 kernel hangs (or at least progresses extremely slowly) > on boot, does not bring up guest graphical interface within the first > 10 minutes that I waited for it. That, in contrast with the default > nop-based emulation where the guest comes up within 30 seconds. Thanks a lot, meanwhile I'll try to write a unit-test and experiment with various behaviours. > I will run another round of tests on a newer Mac (4-year-old macbook > air) and report back tomorrow. > > Going off on a tangent, why would encouraging otherwise well-behaved > guests (like linux ones, for example) to use MWAIT be desirable to > begin with ? Is it a matter of minimizing the overhead associated with > exiting and re-entering L1 ? Because if so, AFAIR staying inside L1 and > running guest-mode MWAIT in a tight loop will actually waste the host > CPU without the opportunity to yield to some other L0 thread. Sorry if > I fell into the middle of an ongoing conversation on this and missed > most of the relevant context, in which case please feel free to ignore > me... :) > > Thanks, > --G It's just some experiments I'm running, I'm not ready to describe it yet. I thought this part might be useful to at least some guests, so trying to upstream it right now. -- MST