Received: by 10.223.185.116 with SMTP id b49csp1307340wrg; Wed, 14 Feb 2018 15:08:18 -0800 (PST) X-Google-Smtp-Source: AH8x227JYshFyIXIT/2IWttxfhsJlWutgz+jEglOZcwcQQdW/tkXTiS6hrVno7ETiI+Z3BtTB88b X-Received: by 10.101.82.130 with SMTP id y2mr521075pgp.68.1518649698423; Wed, 14 Feb 2018 15:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518649698; cv=none; d=google.com; s=arc-20160816; b=ahODiEFdiVAFJG4A67EjlxzH0e/fipqIszEDH2ZlJamCNYFIyt5u0DlhGATc1LXlT7 D/ybafu7sHoLU0eA/vXbo0LRo2fJupamd7uWxPv8I2UhWvaBAUw7X9FV4zfUFFFpEJ7t R1DB72IVxrxbP7s4xFGWK9tKAEvwzfd3b2EI+NMk4FAc9luqN66/F4cUhrUC9bb2/OWn zDbqxvaT4wQU0RbomYZJFIp09JLVucULk3nISfxigYLCPfCp6Jv2XcP0kz07O6ZyQLCO HzrFA7l1VpoEvtTh4F8PAv1XxNeV+ozz+nD8wUp/X2tc28Sztu6acuDDX8/4YOh25nXG iZiw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=i5Zhlz3m/ob7Kbl9TLFAyY2CbsbPRE46XDXxRpS4ChQ=; b=FG7XslIHIkfxFamPkcIKnuIh5LmgBcs9tPKLzDVLDX5E1s0dHThIqRYjv3ZFH0VHa0 DwngIHsI52eDMkW/wmdE7tQrg2TdtmL/qPDX+L02D3JqrwMJp67SuB+J4/mK7nTskXjv Rb8Ixirqxj0knX6D8rBTJHx+wfZvijsU3UrdHeTQqMCm6g78Xt35V7pFRoCU9zRt2sYf RRYIF00D+qWUrr/H/pCGsmsKVsaS6oIFtVM16uwfjI+dRcavPP8/zW3pe9uvZXN2FE0y nPuGCWiVArDIRMdA620GsG/O2UQ1m5zbY86XsT/PDSOnJaTLlZo6VDfMVjuQHvyQlFmd YOBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KPOhAKYT; 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 b2-v6si1117793plm.172.2018.02.14.15.08.03; Wed, 14 Feb 2018 15:08:18 -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=@gmail.com header.s=20161025 header.b=KPOhAKYT; 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 S1031993AbeBNXHZ (ORCPT + 99 others); Wed, 14 Feb 2018 18:07:25 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37200 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031852AbeBNXHX (ORCPT ); Wed, 14 Feb 2018 18:07:23 -0500 Received: by mail-wm0-f66.google.com with SMTP id v71so24783693wmv.2 for ; Wed, 14 Feb 2018 15:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=i5Zhlz3m/ob7Kbl9TLFAyY2CbsbPRE46XDXxRpS4ChQ=; b=KPOhAKYTVvZhusgJqiS7RAdtrCl29SJuoNTwYdIzvf3PgIUz13XDbzoe7jATioVf2w Jo/i1twLHOPMsc+OjSUMdgzwyucIw6gjpMDWnvYdD8+brFMBD4UzcZZVXbfJOdfPVliW DjDINyfamUXB7FVbMzFo3ZFa08jhWLkyW1VzL1j6LdpA5phx4JDUgNlv9RyKNQLtWwH9 EzaR0gGunKf5AhIIMlsWiq0nySIpFb9h1FGVoKj+tqNAZmGRVz0kbRsalMFe2aLsfsh7 errUYfuqT4akzC6D7uKc1pmZhcTfbn44kvoVyRTop6gTt2XEghf6i1r1/0gfPvn8K9ZI wyAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=i5Zhlz3m/ob7Kbl9TLFAyY2CbsbPRE46XDXxRpS4ChQ=; b=VJVG/GpOVtvyledi9S7JrE4qGK5ZWRy9tT282WhV8EHzjiwb019qqC/13HceWHDAFC zTIg1iwFrlENCy97KEA6At7+eGGVYR8HzsBNIFmGVLO4n1hJYJTbbd+/r1FHSM5xjblY v0uKfJv9yahsbIrDS7lADovxafGlp9SrnH5SQHVZBJ0pul9t0emllUcJAQYFESWQtwet 8J/UTiRHN6TAXvq5NbB+pzjd6hkmVPssdgjG1qKMiq7nJR3mRdFffSlhXATLNSRl/i9T 5bNCC5HTOgqtO1VfF3+e0Nf7J2fM7rGRlPXLaaCQ6bZSBusSwo6j+k51EaQ0znOewzEg IJ1A== X-Gm-Message-State: APf1xPCZ2tgMOqRFx/KbwLrc/krHdIw2pIFwv1AdJ/yh+/9ZmIRN8zKf 5sAFeMCeKIpd5tJk8jiN9a8= X-Received: by 10.28.239.3 with SMTP id n3mr529874wmh.88.1518649642383; Wed, 14 Feb 2018 15:07:22 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id 7sm14682918wmq.42.2018.02.14.15.07.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 15:07:21 -0800 (PST) Date: Thu, 15 Feb 2018 00:07:18 +0100 From: Ingo Molnar To: Peter Zijlstra Cc: "Yatsina, Marina" , Kees Cook , David Woodhouse , Chandler Carruth , "Kreitzer, David L" , "Grischenko, Andrei L" , "rnk@google.com" , LLVM Developers , "ehsan@mozilla.com" , "Tayree, Coby" , Matthias Braun , Dean Michael Berris , James Y Knight , Guenter Roeck , X86 ML , LKML , Alan Cox , Rik van Riel , Andi Kleen , Josh Poimboeuf , Tom Lendacky , Linus Torvalds , Jiri Kosina , Andy Lutomirski , "Hansen, Dave" , Tim Chen , Greg Kroah-Hartman , Paul Turner , Stephen Hines , Nick Desaulniers , Will Deacon , "David S. Miller" , Peter Zijlstra , Thomas Gleixner , "H. Peter Anvin" Subject: Re: clang asm-goto support (Was Re: [PATCH v2] x86/retpoline: Add clang support) Message-ID: <20180214230718.vjeap2oilb27tlii@gmail.com> References: <20180214090851.GU25181@hirez.programming.kicks-ass.net> <20180214103434.GY25181@hirez.programming.kicks-ass.net> <20180214120417.kwj2jzjvfxbu2vxw@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180214120417.kwj2jzjvfxbu2vxw@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ingo Molnar wrote: > To quantify it: I just performed a test build of a Linux distro kernel config > (Fedora x86-64), and counted the number of callsites that use 'asm goto' > functionality with the v4.15 kernel (including drivers). > > The results: > > Linux distro | !CONFIG_TRACING > ----------------------------------------------------------------------------- > total # of functions : 191,567 | 184,443 > total # of instructions : 14,251,355 | 13,526,112 > ----------------------------------------------------------------------------- > total # of spin_lock*() calls : 25,246 | 25,177 > total # of mutex_lock*() calls : 13,062 | 12,861 > total # of kmalloc*() calls : 5,148 | 5,118 > ----------------------------------------------------------------------------- > total # of 'asm goto' usage sites : 34,851 | 31,059 > total # of 'asm goto' using functions : 18,209 | 16,089 > ----------------------------------------------------------------------------- > percent of kernel functions using 'asm goto' : 9.5% | 8.7% > ----------------------------------------------------------------------------- Here's the size stats of kernel/sched/built-in.o for the same distro config: optimized | no asm goto ----------------------------------------------------------------------------- total # of functions : 765 | 764 total # of instructions : 46,830 | 47,051 I.e. asm goto support reduces scheduler size by ~0.5%, which is a major generated code size reduction. This doesn't count the live branch patching performance advantages: many of those asm goto usage sites are in hot paths, so the performance impact of it is much larger than that: easily a couple of percentage points in scheduler intensive benchmarks, as Peter mentioned. For example here's a thread context switch benchmark comparison on a modern x86 system running a v4.15 kernel: $ perf stat --repeat 20 --sync --null perf bench sched messaging -t -g 25 no asm goto: 0.136778505 seconds time elapsed ( stddev: +- 0.55% ) asm goto optimized: 0.133773904 seconds time elapsed ( stddev: +- 0.51% ) The asm goto enabled kernel is ~2.25% faster in this benchmark, and the performance penalty of not having asm goto support will only increase in the future. i.e. it very much makes sense to implement asm goto support not just for compatibility reasons, but for performance reasons as well. Thanks, Ingo