lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 14 Feb 2018 13:04:17 +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)


* Peter Zijlstra <peterz@...radead.org> 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ