Received: by 10.223.185.116 with SMTP id b49csp594726wrg; Wed, 14 Feb 2018 04:05:22 -0800 (PST) X-Google-Smtp-Source: AH8x225c6VPCCAfjnE88Ubcs2cDIIT6nu7re/gqI8Hqw0I7lDpToV9rBwikH9vEqH0l0piXEwWaa X-Received: by 2002:a17:902:2881:: with SMTP id f1-v6mr4237020plb.439.1518609922150; Wed, 14 Feb 2018 04:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518609922; cv=none; d=google.com; s=arc-20160816; b=sXqWSK+ThY5bsptV2XipAAA6QqFseqqPWie6N3Y+kPrUDuiFStoNTB38tmliR/SEPy 2uzNApRDpsM+tqO6/1KwmsR7Jqjx7KL1z6m0TzP6Y5W9hhx1Lvqthb3OYHLoq+qPKngN QiqYBR66W0DeZJzeQ/rP0hpBpfg9zudfsvwd/Ft7h085i1C4sXTQ7GC1sxeieDEEMfp2 xAibDW6OPLz/j8fEejDzz65mmyr01KKjo2FrPj0aV7H2TIXeAqUGQxViWfT+9N2dHb2m kkmS28DNWfJjI1lEVl5nDxvOp9EYGCaVrw7izVE8CFYQ8o9J0qnu5hZIrVotF/JP2v4h o8iA== 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=D5RRmQ1jPxu48MR6qSczoz8Vnmt1FF0DFhW7VkyNbYc=; b=J0ddCTZNpgU8x+FurSSwoRnEz6sRGRREYhjAev3F+aVjgjGLs2sFToykuAslzVSaGz Ec67/teBbxweYHG/1d+jCr3K+uYAo4uvZrGq4k1IQjRc/k/ysJu86dlIgbtv9gVjKs2I AUysyIpbhidpi6SGN5bMl0wdZpq8Anw9vF70thX+IDJjyJkEdBAKpVZ7MJuhn7+znP6L 76j579tfNy0qkxuzmU5mkCunAK1/7UjbchWZV+9AaPWKbIbG1FEcEpFqRB3deJj50Zys huZVXsenbUCzyM8Bjq+JRGh8R7rYWJVt3DGnDLYNhAVFo+z3/XaUVLC8x0Q/QKFKWB4K +roQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kxT0PjGy; 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 3-v6si1289423plz.209.2018.02.14.04.05.07; Wed, 14 Feb 2018 04:05:22 -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=kxT0PjGy; 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 S967697AbeBNMEX (ORCPT + 99 others); Wed, 14 Feb 2018 07:04:23 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52132 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967650AbeBNMEW (ORCPT ); Wed, 14 Feb 2018 07:04:22 -0500 Received: by mail-wm0-f65.google.com with SMTP id r71so22223641wmd.1 for ; Wed, 14 Feb 2018 04:04:21 -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=D5RRmQ1jPxu48MR6qSczoz8Vnmt1FF0DFhW7VkyNbYc=; b=kxT0PjGySMiluXd6EsZkHxcNiNYnL0Sng58+czBzOboSektBxHpYE3j1o6PqD/+D8E BpmfyI0Oa2CDd7HeHu8al2vohl3qx8Jl7aK9lsJGzaErP9Jhci+vj23kSiUc7+kSHgMx V4TZ6ij6rd7YeX750aqyvo+XY8/nyB3P7xAF80kQHdgB3V02m/+EjokNpM3aTLeDUGii UjJqwiQsZeZ9adPWN8UzU6r16kpqrg/+hNgy6/bzCpA6zTUYv8xDyZrOVI55zbDjyleE hXFhGEZq4XiAyQcGAjyEpr0XDk8JggAI2dTWhASyuQiwStJ2eANBewzE0QoQD6tyQLkM HrCA== 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=D5RRmQ1jPxu48MR6qSczoz8Vnmt1FF0DFhW7VkyNbYc=; b=qAavvatLWw/EJk5z4ATLqOkfeUJUXZ1ZJ+ox3avYcgJ1Lv98J809XZmd+N8L0j3kg5 a3sn/oH3oSTNIERI5TZbCl47UI891QrqZSdp3ljHxRXItAKFJXcXv4SsNwwEv/7lsdur HnD3g+6FoXizl5I2QD6zD6epsgM+W4ZTxQqevj7uwBM7O77o+U+iPmn9kcOww/3zt5b5 sTm1dTnmdpIi4ppEuiSqzEEB/2xRJzaj2UEwKL9pgCbNvqO2bwG6MGrvCQspy4O009EH BLuRXkuxrho4h0OdAg/g9UVnoIXal2DvmRNm95WO2BNcdtO5LGDkr6drrbueFDRPJbxH 1SCw== X-Gm-Message-State: APf1xPAmoxysnsbWJoZPOqMc5K/5gN/V2OJtqW5fOS7cc3Gs9HkBt0II u5Z/oFhwtn94zLr+XpsNrt8= X-Received: by 10.28.214.67 with SMTP id n64mr3667953wmg.25.1518609861039; Wed, 14 Feb 2018 04:04:21 -0800 (PST) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id 77sm15465447wmt.37.2018.02.14.04.04.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 04:04:20 -0800 (PST) Date: Wed, 14 Feb 2018 13:04:17 +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: <20180214120417.kwj2jzjvfxbu2vxw@gmail.com> References: <20180214090851.GU25181@hirez.programming.kicks-ass.net> <20180214103434.GY25181@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180214103434.GY25181@hirez.programming.kicks-ass.net> 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 * Peter Zijlstra wrote: > On Wed, Feb 14, 2018 at 09:52:59AM +0000, Yatsina, Marina wrote: > > Hi Peter, > > > > When I started the original thread last year I was in favor of adding > > "asm goto" and didn't understand why it wasn't done by that time. The > > feedback I got is that this feature (optimizing tracepoints) is very > > useful and that we do want it in llvm, but perhaps there's a cleaner > > way of implementing than "asm goto". An alternative suggestion arose > > as well. > > So it's far more than just tracepoints. We use it all over the kernel to > do runtime branch patching. > > One example is avoiding the scheduler preemption callbacks if we know > there are no users. This shaves a few % off a context switch > micro-bench. > > But it is really _all_ over the place. 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% ----------------------------------------------------------------------------- ( Note: I added the 'tracing disabled' column only to demonstrate how widely 'asm goto' is used beyond tracing - but since *all* major Linux distributions have tracing enabled it's the first column that matters in practice. ) So 'asm goto' is a major, major compiler feature the Linux kernel relies on: in fact in the Linux kernel there's more 'asm goto' usage sites than there are spin-lock critical sections! Thanks, Ingo