From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752126AbeBBVYW (ORCPT ); Fri, 2 Feb 2018 16:24:22 -0500 Received: from www.llwyncelyn.cymru ([82.70.14.225]:37072 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbeBBVYQ (ORCPT ); Fri, 2 Feb 2018 16:24:16 -0500 Date: Fri, 2 Feb 2018 21:23:33 +0000 From: Alan Cox To: David Woodhouse Cc: Linus Torvalds , Thomas Gleixner , KarimAllah Ahmed , sironi@amazon.de, the arch/x86 maintainers , KVM list , Paolo Bonzini , Linux Kernel Mailing List , Borislav Petkov , Peter Zijlstra Subject: Re: [PATCH] KVM: x86: Reduce retpoline performance impact in slot_handle_level_range() Message-ID: <20180202212321.5186c13c@alans-desktop> In-Reply-To: <1517599033.31953.71.camel@infradead.org> References: <1517583559-424-1-git-send-email-dwmw@amazon.co.uk> <1517599033.31953.71.camel@infradead.org> Organization: Intel Corporation X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Either way, that does look like a reasonable answer. I had looked at > the various one-line wrappers around slot_handle_level_range() and > thought "hm, those should be inline", but I hadn't made the next step > and pondered putting the whole thing inline. We'll give it a spin and > work out where the next performance bottleneck is. Thanks. In addition the problem with switch() is that gcc might decide in some cases that the best way to implement your switch is an indirect call from a lookup table. For the simple case how about wrapping the if into call_likely(foo->bar, usualfunction, args) as a companion to foo->bar(args) that can resolve to nothing special on architectures that don't need it, an if/else case on platforms with spectre, and potentially clever stuff on any platform where you can beat the compiler by knowing probabilities it can't infer ? Alan