Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1735048

Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more clear and consistent

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more clear and consistent
Date 2017-09-19 18:10 +0200
Message-ID <urtfX-7CA-7@gated-at.bofh.it> (permalink)
References (1 earlier) <ukyu5-6Gt-7@gated-at.bofh.it> <ukAmd-7Ri-9@gated-at.bofh.it> <ukBrY-4T-13@gated-at.bofh.it> <uq2Bb-61b-17@gated-at.bofh.it> <uq3dT-6zx-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more  clear and consistent Linus Torvalds <torvalds@linux-foundation.org> - 2017-09-15 20:10 +0200
  Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more  clear and consistent Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-16 01:30 +0200
    Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more  clear and consistent Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-18 19:50 +0200
  Re: [RFC PATCH 3/4] x86/asm: Make alternative macro interfaces more  clear and consistent Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-19 18:10 +0200

csiph-web