[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180214230718.vjeap2oilb27tlii@gmail.com>
Date: Thu, 15 Feb 2018 00:07:18 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "Yatsina, Marina" <marina.yatsina@...el.com>,
Kees Cook <keescook@...gle.com>,
David Woodhouse <dwmw2@...radead.org>,
Chandler Carruth <chandlerc@...gle.com>,
"Kreitzer, David L" <david.l.kreitzer@...el.com>,
"Grischenko, Andrei L" <andrei.l.grischenko@...el.com>,
"rnk@...gle.com" <rnk@...gle.com>,
LLVM Developers <llvm-dev@...ts.llvm.org>,
"ehsan@...illa.com" <ehsan@...illa.com>,
"Tayree, Coby" <coby.tayree@...el.com>,
Matthias Braun <matze@...unis.de>,
Dean Michael Berris <dean.berris@...il.com>,
James Y Knight <jyknight@...gle.com>,
Guenter Roeck <linux@...ck-us.net>, X86 ML <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Alan Cox <gnomes@...rguk.ukuu.org.uk>,
Rik van Riel <riel@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Tom Lendacky <thomas.lendacky@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jiri Kosina <jikos@...nel.org>,
Andy Lutomirski <luto@...capital.net>,
"Hansen, Dave" <dave.hansen@...el.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...ux-foundation.org>,
Paul Turner <pjt@...gle.com>,
Stephen Hines <srhines@...gle.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Will Deacon <will.deacon@....com>,
"David S. Miller" <davem@...emloft.net>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: clang asm-goto support (Was Re: [PATCH v2] x86/retpoline: Add
clang support)
* Ingo Molnar <mingo@...nel.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
Powered by blists - more mailing lists