[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170919160210.beip7uighuq7gqu3@treble>
Date: Tue, 19 Sep 2017 11:02:10 -0500
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andrey Ryabinin <aryabinin@...tuozzo.com>,
the arch/x86 maintainers <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Alexander Potapenko <glider@...gle.com>,
Dmitriy Vyukov <dvyukov@...gle.com>,
Matthias Kaehlcke <mka@...omium.org>,
Arnd Bergmann <arnd@...db.de>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more
clear and consistent
On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote:
> And most code movement really seemed to be around inline asms, I
> wonder if the gcc logic simply is something like "if the stack pointer
> is visible as a register, don't move any inline asm across a frame
> setup".
After some testing, that seems to be exactly right. Making the stack
pointer a global register variable seems to cause *all* inline asm to be
treated like it has a call instruction.
And setting the stack pointer as a constraint becomes a no-op.
So basically if we just put
register void *__asm_call_sp asm(_ASM_SP);
in a globally visible header file (e.g., arch/x86/include/asm/asm.h), it
will *always* make sure the frame pointer is set up before inserting
*any* inline asm.
The upside is that we don't have to manually annotate inline asm anymore
with those awful "+r" (__sp) constraints.
The downside is that this creates a very slight performance issue for
leaf functions which use inline assembly without call instructions,
because they're getting frame pointer setup when they don't need it.
But based on the text size difference, the performance impact should be
negligible. And it's only an issue for frame pointer-based kernels,
which may soon no longer be the default anyway.
And for non-frame-pointer-based kernels, it actually saves quite a bit
of text.
In GCC, here are the vmlinux .text size differences with the following
configs:
- defconfig
- defconfig without frame pointers
- Fedora distro config
- Fedora distro config without frame pointers
defconfig defconfig-nofp distro distro-nofp
before 9796300 9466764 9076191 8789745
after 9796941 9462859 9076381 8785325
If there are no objections, I'll go forward with the patch.
--
Josh
Powered by blists - more mailing lists