Received: by 10.213.65.68 with SMTP id h4csp537523imn; Tue, 13 Mar 2018 12:14:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELsmWKl+JWIyPBqhQsDFz4pe9MyNit64NsH4Dx5ukTa4s6e3tHgkPKySyvrbE7N4PBL6MBAj X-Received: by 10.98.186.2 with SMTP id k2mr1598632pff.225.1520968482684; Tue, 13 Mar 2018 12:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520968482; cv=none; d=google.com; s=arc-20160816; b=mEGaWLVhXRDSIuGthK5OrxPT/bRHB/BZLrS3NmRO32idVVuo+TeB/nKN7Bfk6r0zIL ve+3jTF0bfSGOQni/Fv+h6LR1IJx4J8sfExs5CNrE8ZMlLsFk518nXeaLDkeWttBYDOM IiFcDLYspZ9GTAFOM8yCSf46GyfWPyaX/gpSxTx7gi3JFeznYtXtp+5mvvROA++TrHP1 8SccUcOH0bunx+bpmyNeGmovqEFrNa2iE/yklpd/yv1v15uwinHl/aCm3pRDZT0hkay/ 1f8FqQA5OL7H2dHDVoxWNoEkCCu1sVjNcSPzXrw5TiOS5qhD2wrZamv7gzxy/AJRsSNw vfHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=vjd9Q60DDBltmGiB3EvRAcLKuZ5cfr/MiSMhoiBCwqc=; b=FMOoF8Fc3GrQxSbjDRcSUZheRflI+cvZoMOPdbMnZq7OCY88/+EHVM+YeBjJrObh+y rAiOm53YraUrjcgoXyWHranX8mKd65wQAx198XFTh+TiLlV7gwEueirqNJiCB+pmf0x9 n3H1EgAw462jRSQcvkI3l211ZMoLb21gfPMcppJRUXETVJjc7DDRgyCQdORvi3WtLdCA UeniUUItf3fOmcAiIBNpxKQI2sO8fLwQbyKx/uoaa+njyHhqtx+9I/F+tynlTFYJdiaO LSpfXWkXCWWr/14aj0TiWhQY5wu7CB8+AkPSXWt82BrQ2Q455sIN4AWWHtRZXwK+7lDI MqlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a68si192010pgc.467.2018.03.13.12.14.27; Tue, 13 Mar 2018 12:14:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752431AbeCMTNa (ORCPT + 99 others); Tue, 13 Mar 2018 15:13:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57548 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752000AbeCMTN2 (ORCPT ); Tue, 13 Mar 2018 15:13:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44DCE406802A; Tue, 13 Mar 2018 19:13:28 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 6DFE92026DFD; Tue, 13 Mar 2018 19:13:25 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Tue, 13 Mar 2018 20:12:43 +0100 Date: Tue, 13 Mar 2018 20:12:42 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Vitaly Kuznetsov Cc: Paolo Bonzini , Thomas Gleixner , kvm@vger.kernel.org, x86@kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 7/7] x86/kvm: use Enlightened VMCS when running on Hyper-V Message-ID: <20180313191242.GB13426@flask> References: <20180309140249.2840-1-vkuznets@redhat.com> <20180309140249.2840-8-vkuznets@redhat.com> <87r2opcr6u.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r2opcr6u.fsf@vitty.brq.redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Mar 2018 19:13:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 13 Mar 2018 19:13:28 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-12 15:19+0100, Vitaly Kuznetsov: > Thomas Gleixner writes: > > > On Fri, 9 Mar 2018, Vitaly Kuznetsov wrote: > > > >> Enlightened VMCS is just a structure in memory, the main benefit > >> besides avoiding somewhat slower VMREAD/VMWRITE is using clean field > >> mask: we tell the underlying hypervisor which fields were modified > >> since VMEXIT so there's no need to inspect them all. > >> > >> Tight CPUID loop test shows significant speedup: > >> Before: 18890 cycles > >> After: 8304 cycles > >> > >> Static key is being used to avoid performance penalty for non-Hyper-V > >> deployments. Tests show we add around 3 (three) CPU cycles on each > >> VMEXIT (1077.5 cycles before, 1080.7 cycles after for the same CPUID > >> loop on bare metal). We can probably avoid one test/jmp in vmx_vcpu_run() > >> but I don't see a clean way to use static key in assembly. > > > > STATIC_JUMP_IF_TRUE, STATIC_JUMP_IF_FALSE are your friends. > > > > Thanks for the tip, > > with a single kernel user of these APIs it was easy to miss :-) Indeed, I had no idea. > Unfortunately, these APIs are only present if HAVE_JUMP_LABEL and > (afaiu) we still care about KVM on !HAVE_JUMP_LABEL builds. It would be > nice if we can make them behave the same way static_branch_likely() and > friends do: compile into something else when !HAVE_JUMP_LABEL so we can > avoid nasty #ifdefs in C code. > > That said I'd like to defer the question to KVM maintainers: Paolo, > Radim, what would you like me to do? Use STATIC_JUMP_IF_TRUE/FALSE as > they are, try to make them work for !HAVE_JUMP_LABEL and use them or > maybe we can commit the series as-is and have it as a future > optimization (e.g. when HAVE_JUMP_LABEL becomes mandatory)? Please take a look into making a macro that uses STATIC_JUMP_IF_FALSE or reads the value from provided static_key and does a test-jump, depending on HAVE_JUMP_LABEL. It doesn't need to be suited for general use, just something that moves the ugliness away from vmx_vcpu_run. (Although having it in jump_label.h would be great. I think the main obstacle is clobbering of flags.) If it were still looking horrible, I'm ok with the series as-is, thanks.