From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH] KVM: x86: Reduce retpoline performance impact in slot_handle_level_range() Date: Mon, 5 Feb 2018 09:51:24 +0100 Message-ID: <20180205085124.GF2249@hirez.programming.kicks-ass.net> References: <1517583559-424-1-git-send-email-dwmw@amazon.co.uk> <1517599033.31953.71.camel@infradead.org> <20180202212321.5186c13c@alans-desktop> <1517669207.31953.120.camel@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: Alan Cox , Linus Torvalds , Thomas Gleixner , KarimAllah Ahmed , sironi@amazon.de, the arch/x86 maintainers , KVM list , Paolo Bonzini , Linux Kernel Mailing List , Borislav Petkov , Paul Turner To: David Woodhouse Return-path: Received: from merlin.infradead.org ([205.233.59.134]:44998 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbeBEIvr (ORCPT ); Mon, 5 Feb 2018 03:51:47 -0500 Content-Disposition: inline In-Reply-To: <1517669207.31953.120.camel@infradead.org> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, Feb 03, 2018 at 02:46:47PM +0000, David Woodhouse wrote: > > 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 ? > > Yeah. I'm keen on being able to use something like alternatives to > *change* 'usualfunction' at runtime though. I suspect it'll be a win > for stuff like dma_ops. > > But I'm also keen to actually base such things on real data, not just > go randomly "optimising" stuff just because we can. Let's try to make > sure we fix up the real bottlenecks, and not just go crazy. Google has a fairly long history of using feedback driven optimization compiles for the kernel. They were also the ones that developed perf autofdo tooling IIRC. https://gcc.gnu.org/wiki/AutoFDO/Tutorial One of the things pjt promised was a series of patches doing the proposed optimization for the scheduler code based on their results.