Received: by 10.213.65.68 with SMTP id h4csp80684imn; Mon, 12 Mar 2018 07:21:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELu2tKm04QpvqLNZLqywiQeUq6ukWaQUOwpqGXmaHavuK8yhBhr/W/Z5S5yaFsRsYF1xTUIC X-Received: by 10.99.95.75 with SMTP id t72mr6208985pgb.411.1520864519231; Mon, 12 Mar 2018 07:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520864519; cv=none; d=google.com; s=arc-20160816; b=JXL8UNYF8oaLIKtF0iNh3ce9wyu8JyC8F6k/gwZ9Hv5SS+F2v475lJAjqY7yNq+a+I 8x68GEDdZoH2EwCIDapqsvwNYqVCdtOxWchrRkbpgvjx+fL/jlF5ejargcEuHPig4EbN /d/PsSp0ydD5u2Kk4N2mpyUBKrqomJeTy1W7c+mvEchWR4A2fIjQtYlxpfOEuTdthmP7 fJrMuQf0ChilQJ4wzZQBrZYPMT+u/vH1vpTt8FsELAkkr7EjNwp1/+YUb054s9fylQFK D5Sydr5n6oxoLj0izyJezivLxz5OLi5Yg0AyI5zOAv6F/vXsTsaTa1iUPGLs1ZDKKOjN AzUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=ovK+rexTZpN3vF9FNk+zAWPKDaxoKyeb0c1mHbsgyZo=; b=RpR8q5QQ1evVuJqyn7XvhBQlwvosUxri8USrxXr9qRC9f/yNyEDk+hjC7y6ED4aFXU w7w5KHcaoPLucz9B9Sx+aK5UGZTHViLzsDjLTfwzuOD0N/cggstyo24AsY13yEubKV9n yxZRmFLhETihvxeFYEe0lJt0itanZE2VX7D3Uy9lOD+BGjGVUmeZwoRDOaqphOXzDU/g Dd152jFGiHM9venyjAPN+aIZeq12fpvK1Nk9tXoiNhM9uC3bYbHBepGM/pdp7Mq/B3Vx OI9DKAOXGPne4bzBAqwXl5gCw1JcVqkNA90tArEX3eiXckjhCj8QsQCqLSsKd2e+FGQR WaCA== 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 l12si5099579pgr.66.2018.03.12.07.21.44; Mon, 12 Mar 2018 07:21:59 -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 S1751751AbeCLOTM (ORCPT + 99 others); Mon, 12 Mar 2018 10:19:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44748 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751232AbeCLOTL (ORCPT ); Mon, 12 Mar 2018 10:19:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8E2740201A3; Mon, 12 Mar 2018 14:19:10 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3F5A10B0F3E; Mon, 12 Mar 2018 14:19:06 +0000 (UTC) From: Vitaly Kuznetsov To: Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner Cc: 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 References: <20180309140249.2840-1-vkuznets@redhat.com> <20180309140249.2840-8-vkuznets@redhat.com> Date: Mon, 12 Mar 2018 15:19:05 +0100 In-Reply-To: (Thomas Gleixner's message of "Fri, 9 Mar 2018 15:08:34 +0100 (CET)") Message-ID: <87r2opcr6u.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 12 Mar 2018 14:19:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 12 Mar 2018 14:19:10 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :-) 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)? -- Vitaly