All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Yatsina, Marina" <marina.yatsina@intel.com>,
	Kees Cook <keescook@google.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Chandler Carruth <chandlerc@google.com>,
	"Kreitzer, David L" <david.l.kreitzer@intel.com>,
	"Grischenko, Andrei L" <andrei.l.grischenko@intel.com>,
	"rnk@google.com" <rnk@google.com>,
	LLVM Developers <llvm-dev@lists.llvm.org>,
	"ehsan@mozilla.com" <ehsan@mozilla.com>,
	"Tayree, Coby" <coby.tayree@intel.com>,
	Matthias Braun <matze@braunis.de>,
	Dean Michael Berris <dean.berris@gmail.com>,
	James Y Knight <jyknight@google.com>,
	Guenter Roeck <linux@roeck-us.net>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alan Cox <gnomes@lxorguk.ukuu.org.uk>,
	Rik van Riel <riel@redhat.com>, Andi Kleen <ak@linux.intel.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jiri Kosina <jikos@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	"Hansen, Dave" <dave.hansen@intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linux-foundation.org>,
	Paul Turner <pjt@google.com>, Stephen Hines <srhines@google.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Will Deacon <will.deacon@arm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: clang asm-goto support (Was Re: [PATCH v2] x86/retpoline: Add clang support)
Date: Thu, 15 Feb 2018 00:07:18 +0100	[thread overview]
Message-ID: <20180214230718.vjeap2oilb27tlii@gmail.com> (raw)
In-Reply-To: <20180214120417.kwj2jzjvfxbu2vxw@gmail.com>


* Ingo Molnar <mingo@kernel.org> 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

  reply	other threads:[~2018-02-14 23:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  0:28 clang asm-goto support (Was Re: [PATCH v2] x86/retpoline: Add clang support) Kees Cook
2018-02-14  8:33 ` Yatsina, Marina
2018-02-14  8:41   ` Chandler Carruth
2018-02-14  9:10     ` Peter Zijlstra
2018-02-14 10:44       ` Thomas Gleixner
2018-02-14  9:53     ` Greg Kroah-Hartman
2018-02-14 10:07       ` Yatsina, Marina
2018-02-14 10:17         ` Chandler Carruth
2018-02-14  9:08   ` Peter Zijlstra
2018-02-14  9:52     ` Yatsina, Marina
2018-02-14 10:34       ` Peter Zijlstra
2018-02-14 12:04         ` Ingo Molnar
2018-02-14 23:07           ` Ingo Molnar [this message]
2018-02-14 17:39         ` Linus Torvalds
2018-02-14 17:31     ` Kees Cook
2018-02-14 18:39       ` Peter Zijlstra
2018-02-14 15:31   ` James Y Knight
2018-02-14 17:21     ` Andy Lutomirski
2018-02-14 17:43     ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214230718.vjeap2oilb27tlii@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ak@linux.intel.com \
    --cc=andrei.l.grischenko@intel.com \
    --cc=chandlerc@google.com \
    --cc=coby.tayree@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=davem@davemloft.net \
    --cc=david.l.kreitzer@intel.com \
    --cc=dean.berris@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=ehsan@mozilla.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=jyknight@google.com \
    --cc=keescook@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=llvm-dev@lists.llvm.org \
    --cc=luto@amacapital.net \
    --cc=marina.yatsina@intel.com \
    --cc=matze@braunis.de \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=riel@redhat.com \
    --cc=rnk@google.com \
    --cc=srhines@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.