Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754112AbdDDNPw (ORCPT ); Tue, 4 Apr 2017 09:15:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:57771 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753254AbdDDNPt (ORCPT ); Tue, 4 Apr 2017 09:15:49 -0400 Subject: Re: [PATCH v5 untested] kvm: better MWAIT emulation for guests To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <1489612895-12799-1-git-send-email-mst@redhat.com> <87f187de-64ef-22a2-7714-a811883bce02@suse.de> <20170328142837.GA21738@potion> <20170329121147.GA5129@potion> <20170404123915.GA9525@potion> <20170404131308.GA9826@potion> Cc: Jim Mattson , "Michael S. Tsirkin" , LKML , "Gabriel L. Somlo" , Paolo Bonzini , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , the arch/x86 maintainers , Joerg Roedel , kvm list , linux-doc@vger.kernel.org From: Alexander Graf Message-ID: Date: Tue, 4 Apr 2017 15:15:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170404131308.GA9826@potion> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2010 Lines: 45 On 04/04/2017 03:13 PM, Radim Krčmář wrote: > 2017-04-04 14:51+0200, Alexander Graf: >> On 04/04/2017 02:39 PM, Radim Krčmář wrote: >>> 2017-04-03 12:04+0200, Alexander Graf: >>>> So coming back to the original patch, is there anything that should keep us >>>> from exposing MWAIT straight into the guest at all times? >>> Just minor issues: >>> * OS X on Core 2 fails for unknown reason if we disable the instruction >>> trapping, which is an argument against doing it by default >> So for that we should try and see if changing the exposed CPUID MWAIT leaf >> helps. Currently we return 0/0 which is pretty bogus and might be the reason >> OSX fails. > We have tried to pass host's CPUID MWAIT leaf and it still failed: > https://www.spinics.net/lists/kvm/msg146686.html > > I wouldn't mind breaking that particular combination of OS X and > hardware, but I'm worried to do it because we don't understand why it > broke, so there could be more ... > >>> * idling guests would consume host CPU, which is a significant change >>> in behavior and shouldn't be done without userspace's involvement >> That's the same as today, as idling guests with MWAIT would also today end >> up in a NOP emulated loop. >> >> Please bear in mind that I do not advocate to expose the MWAIT CPUID flag. >> This is only for the instruction trap. > Ah, makes sense. > >>> I think the best compromise is to add a capability for the MWAIT VM-exit >>> controls and let userspace expose MWAIT if it wishes to. >>> Will send a patch. >> Please see my patch to force enable CPUID bits ;). > Nice. MWAIT could also use setting of arbitrary values for its leaf, > but a generic interface for that would probably look clunky on the > command line ... I think we should have an interface similar to smbios for that eventually. Something where you can explicitly set arbitrary CPUID leaf information using leaf specific syntax. There are more leafs where it would make sense - cache topology for example. Alex