Received: by 10.223.176.5 with SMTP id f5csp2269992wra; Mon, 5 Feb 2018 00:53:56 -0800 (PST) X-Google-Smtp-Source: AH8x2242TcVOd3BuwyHhPQklm04RWuVM7uMxaH77XqF7PJ1WyWY6RAok+q1bay9PUCAmw7eLJ8Md X-Received: by 2002:a17:902:6087:: with SMTP id s7-v6mr41976891plj.6.1517820836072; Mon, 05 Feb 2018 00:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517820836; cv=none; d=google.com; s=arc-20160816; b=Je32yQfaO8Rn38F6QkAWS0uyTv5fY0R8QSfygCxS328ueQJsZFN3Pz1Iq+8U6+F0wb HfZpSjD6huiYa9XVljI1K/17ImenTh0JwQJAAGGB9ZotfKp0h9eGp69b3Cr8KqWUC/Sd BkOZrefbYpOCicbE2jTd5IllxjBxiL1xObk6ze+pYWXiN2WZrlfeX5IsDRR/q4/JeAzk YlgB7GTwXCH/Dqjx8s5BHJrXEgwEm9uMkj/iXKwDDNY4nuJpBinHWgGKYebOTZ7qdn2R 4LfXE171GIJ/z91FopWZe7WHbbkgwN40fQKM+MJO2LbzRjSxjncV8VON+P2Y1GY5dfiF yqlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=gdQHbX8wbNNrNdxWOb4x70JjPT+f36cb18mW5Ur3sj8=; b=xC8CePnnTvbSL8dovSb6hIDbrr2RqVelPFQLRdMeYehJiIl6uaf4SQlFDm6ufnPbhx XoSJzuk0oJctKOzBQBVLqyueCX14A4gLl/8zr+vgo3r6uhhnbSCwukiWYR/kLRTBoj/p AHJRLPJTQkBQScPXYhCmB7I+3tcXFeGSP7PvbG1To0gNgM/zpDCGIyQrwIB9Er0wxUCE 3Mq/80WgeqzO6w1lD3DABxPgCEY1IdlFGnj+JxLoEshAMfy3Jq6XWvefsrwHEJQeThle 2WvHYjDn4yCfFH3NL1eGHhnw/H0IAaY1Gv3ypwB8PpWC6P7DjO4KfFhdIbPxQ8vF77fN MTUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=CLn0vE0S; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si5200331pgp.577.2018.02.05.00.53.41; Mon, 05 Feb 2018 00:53:56 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=CLn0vE0S; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbeBEIvy (ORCPT + 99 others); Mon, 5 Feb 2018 03:51:54 -0500 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gdQHbX8wbNNrNdxWOb4x70JjPT+f36cb18mW5Ur3sj8=; b=CLn0vE0Sd/0FFZc023YN6HjXLY O/dYXRnyXNuGWH8qlfLbCmgHlnTDAWH2JCqVohQHUA99tvMCeI/5xKfodSC3K8jhtqchUCEY9mA2W JNnqZopAGKHLljlSMquOLRY0ZcychPVuNGixY+AKwD2raiyXScSwJtnlRcJA61Vw1CuEPHzOu1qy2 9wMwx+bcKg+G8Klpvn/oEHtntsIrp/RYgJRXNi91A2iglbSasAwAzzvsY813cNJjCOpAjfxu4CqpS 08Ydy7R5w5SxJn9vbGOaxdsByzzD5L/+x2SKJwvO65WSqWQ8vsEgldpX0IKsuTMjB+i7N3skS0pXL VyoRme9w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eicUo-0007eC-3X; Mon, 05 Feb 2018 08:51:29 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C1D842029F9F9; Mon, 5 Feb 2018 09:51:24 +0100 (CET) Date: Mon, 5 Feb 2018 09:51:24 +0100 From: Peter Zijlstra To: David Woodhouse 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 Subject: Re: [PATCH] KVM: x86: Reduce retpoline performance impact in slot_handle_level_range() 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1517669207.31953.120.camel@infradead.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.