Received: by 10.223.176.5 with SMTP id f5csp2628729wra; Mon, 5 Feb 2018 07:17:05 -0800 (PST) X-Google-Smtp-Source: AH8x227VFs99vBtGH7TmB67x9Sgt3kC0nQcS3eqX/GoZ/s8wGnJ4sS2xeKtXbz6zIS/hJtaXFRm7 X-Received: by 10.98.80.20 with SMTP id e20mr48816565pfb.148.1517843825435; Mon, 05 Feb 2018 07:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517843825; cv=none; d=google.com; s=arc-20160816; b=VrkKCYntfJzSIxlZhh88zaLVOqAjLh4DaR4HFqHG2f6zzaK8xe1PNpF7xTLgctvk3H KUMJkI+NUM6U3iYjepKa66U82IjhgKoRl//ZloYOFLIgzkpEa1zG1xhq8B9OiMgmQUKu 0nZ01y2bJFzhaMeX+28EKR1HgR2VyQ8NM/YBVIrzHwCgBFkYU2XNgQVS0QAGvRimc3/n nDq+jGblXonKiXnOFUrCMaOxnqd5QzVF55/aqsEEQ34dP2zpagk2aKMjK1phZgJLBDXP 5UWG+aV8qf1p6JYeTr6cjrBovRJcGUh+7tD7mekT8X7A8q7bS0kiZi58h9OuMM8nxNMn puEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=4EnGAuSwjjD9nYPLLouBHQ8TtE/WxuLgtalM47U0C1o=; b=qllJxOM3Fi+nY2mQWqwP9CIKKaRimcIhT5sCEK3z2i0YeuqvSx5HiC9iv/+WyjrMhJ gZ0eqaqcJ9MwvFALfhUAQHMOvBPW2xf99XNGcWC5W9BF7A7oh+2plMMh2cEFQHU5Gn3c kDUj+TTogmMdVfINCF7IPwKxyJj2rHJKf6GnpZwSGPFpafeMaFulk4oXJEHZ6hxi0xyk iOM8r1HixemW6+CD9HIWOGn/wJCakmCDF3So+JdWmKyhsXOyhtwQccxXqE5UpGPFyV7n 8WMD+ExjOEMwE55R1aNip0oiiRWIv6X3ynOi5Rsn9U9qtWb8ncaZYnmMpDyqg1LRLFO8 UXZQ== 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 k5-v6si7259458pln.144.2018.02.05.07.16.50; Mon, 05 Feb 2018 07:17:05 -0800 (PST) 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 S1753219AbeBEPPw (ORCPT + 99 others); Mon, 5 Feb 2018 10:15:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55848 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753136AbeBEPPq (ORCPT ); Mon, 5 Feb 2018 10:15:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FA4733BC6; Mon, 5 Feb 2018 15:15:46 +0000 (UTC) Received: from [10.36.116.201] (ovpn-116-201.ams2.redhat.com [10.36.116.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD5CA6A020; Mon, 5 Feb 2018 15:15:42 +0000 (UTC) Subject: Re: [PATCH] KVM: x86: Reduce retpoline performance impact in slot_handle_level_range() To: Linus Torvalds , David Woodhouse Cc: Thomas Gleixner , KarimAllah Ahmed , sironi@amazon.de, the arch/x86 maintainers , KVM list , Linux Kernel Mailing List , Borislav Petkov , Peter Zijlstra References: <1517583559-424-1-git-send-email-dwmw@amazon.co.uk> From: Paolo Bonzini Message-ID: <362dd50d-67ff-3802-e65d-68949cf80879@redhat.com> Date: Mon, 5 Feb 2018 16:15:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 05 Feb 2018 15:15:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02/2018 19:50, Linus Torvalds wrote: > On Fri, Feb 2, 2018 at 6:59 AM, David Woodhouse wrote: >> With retpoline, tight loops of "call this function for every XXX" are >> very much pessimised by taking a prediction miss *every* time. >> >> This one showed up very high in our early testing, and it only has five >> things it'll ever call so make it take an 'op' enum instead of a >> function pointer and let's see how that works out... > Umm. May I suggest a different workaround? > > Honestly, if this is so performance-critical, the *real* fix is to > actually just mark all those "slot_handle_*()" functions as > "always_inline". I replied quickly from the phone before reading the rest of the thread---yeah, always_inline is the way to go. I see the same differences as Linus and David (slight improvement for slot_handle_*, +1k if you add kvm_handle_hva and kvm_handle_hva_range). At least for slot_handle_* it's a no-brainer. The others are basically the MMU notifier implementation; in the perfect case it should actually never be called (or at least it ought to be very rare), so I think we can keep the indirect calls for now. Paolo