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

2017-09-19 Thread Josh Poimboeuf
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

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

2017-09-19 Thread Josh Poimboeuf
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

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

2017-09-18 Thread Josh Poimboeuf
On Sun, Sep 17, 2017 at 01:22:32AM +0300, Andrey Ryabinin wrote: > On 09/16/2017 02:29 AM, Josh Poimboeuf wrote: > > On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: > >> On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin > >> wrote: > >>> > >>> I'm not so

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

2017-09-18 Thread Josh Poimboeuf
On Sun, Sep 17, 2017 at 01:22:32AM +0300, Andrey Ryabinin wrote: > On 09/16/2017 02:29 AM, Josh Poimboeuf wrote: > > On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: > >> On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin > >> wrote: > >>> > >>> I'm not so sure that this is disabled

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

2017-09-16 Thread Andrey Ryabinin
On 09/16/2017 02:29 AM, Josh Poimboeuf wrote: > On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: >> On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin >> wrote: >>> >>> I'm not so sure that this is disabled optimization. I assume that global >>> rsp makes

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

2017-09-16 Thread Andrey Ryabinin
On 09/16/2017 02:29 AM, Josh Poimboeuf wrote: > On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: >> On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin >> wrote: >>> >>> I'm not so sure that this is disabled optimization. I assume that global >>> rsp makes >>> changes something in

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

2017-09-15 Thread Josh Poimboeuf
On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: > On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin > wrote: > > > > I'm not so sure that this is disabled optimization. I assume that global > > rsp makes > > changes something in gcc's register allocation

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

2017-09-15 Thread Josh Poimboeuf
On Fri, Sep 15, 2017 at 11:01:19AM -0700, Linus Torvalds wrote: > On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin > wrote: > > > > I'm not so sure that this is disabled optimization. I assume that global > > rsp makes > > changes something in gcc's register allocation logic, or something like

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

2017-09-15 Thread Linus Torvalds
On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin wrote: > > I'm not so sure that this is disabled optimization. I assume that global rsp > makes > changes something in gcc's register allocation logic, or something like that > leading > to subtle changes in generated

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

2017-09-15 Thread Linus Torvalds
On Fri, Sep 15, 2017 at 9:53 AM, Andrey Ryabinin wrote: > > I'm not so sure that this is disabled optimization. I assume that global rsp > makes > changes something in gcc's register allocation logic, or something like that > leading > to subtle changes in generated code. > > But what I

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

2017-09-15 Thread Josh Poimboeuf
On Fri, Sep 15, 2017 at 07:53:46PM +0300, Andrey Ryabinin wrote: > > > On 08/31/2017 08:25 PM, Josh Poimboeuf wrote: > > > > There have been a few other ideas which have *almost* worked: > > > > 1) Make the 'register void *__sp asm(_ASM_SP)' a global variable instead > >of a local one.

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

2017-09-15 Thread Josh Poimboeuf
On Fri, Sep 15, 2017 at 07:53:46PM +0300, Andrey Ryabinin wrote: > > > On 08/31/2017 08:25 PM, Josh Poimboeuf wrote: > > > > There have been a few other ideas which have *almost* worked: > > > > 1) Make the 'register void *__sp asm(_ASM_SP)' a global variable instead > >of a local one.

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

2017-09-15 Thread Andrey Ryabinin
On 08/31/2017 08:25 PM, Josh Poimboeuf wrote: > > There have been a few other ideas which have *almost* worked: > > 1) Make the 'register void *__sp asm(_ASM_SP)' a global variable instead >of a local one. This works for GCC and doesn't break clang. However >it resulted in a lot of

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

2017-09-15 Thread Andrey Ryabinin
On 08/31/2017 08:25 PM, Josh Poimboeuf wrote: > > There have been a few other ideas which have *almost* worked: > > 1) Make the 'register void *__sp asm(_ASM_SP)' a global variable instead >of a local one. This works for GCC and doesn't break clang. However >it resulted in a lot of

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

2017-09-15 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 01:45:29PM -0500, Josh Poimboeuf wrote: > On Thu, Sep 14, 2017 at 11:28:30AM -0700, Linus Torvalds wrote: > > On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf > > wrote: > > >> > > >> a) uglifying the 15 or so relevant inline asm locations with

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

2017-09-15 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 01:45:29PM -0500, Josh Poimboeuf wrote: > On Thu, Sep 14, 2017 at 11:28:30AM -0700, Linus Torvalds wrote: > > On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf > > wrote: > > >> > > >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or > > > > > >

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 11:28:30AM -0700, Linus Torvalds wrote: > On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf wrote: > >> > >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or > > > > Actually I guess we could put the "sp" in a macro... I'll try

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 11:28:30AM -0700, Linus Torvalds wrote: > On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf wrote: > >> > >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or > > > > Actually I guess we could put the "sp" in a macro... I'll try it. > > Exactly. Do

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

2017-09-14 Thread Linus Torvalds
On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf wrote: >> >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or > > Actually I guess we could put the "sp" in a macro... I'll try it. Exactly. Do something like #ifdef CONFIG_FRAME_POINTER #

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

2017-09-14 Thread Linus Torvalds
On Thu, Sep 14, 2017 at 10:33 AM, Josh Poimboeuf wrote: >> >> a) uglifying the 15 or so relevant inline asm locations with ifdefs; or > > Actually I guess we could put the "sp" in a macro... I'll try it. Exactly. Do something like #ifdef CONFIG_FRAME_POINTER # define EXTRA_ASM_CLOBBERS

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 12:26:27PM -0500, Josh Poimboeuf wrote: > On Thu, Sep 14, 2017 at 10:16:08AM -0700, Linus Torvalds wrote: > > On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > > > > > As it turns out, the real problem with this option is that it imposes a > >

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 12:26:27PM -0500, Josh Poimboeuf wrote: > On Thu, Sep 14, 2017 at 10:16:08AM -0700, Linus Torvalds wrote: > > On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > > > > > As it turns out, the real problem with this option is that it imposes a > > > penalty for

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 10:16:08AM -0700, Linus Torvalds wrote: > On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > > > As it turns out, the real problem with this option is that it imposes a > > penalty for CONFIG_FRAME_POINTER=n: even with frame pointers disabled,

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

2017-09-14 Thread Josh Poimboeuf
On Thu, Sep 14, 2017 at 10:16:08AM -0700, Linus Torvalds wrote: > On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > > > As it turns out, the real problem with this option is that it imposes a > > penalty for CONFIG_FRAME_POINTER=n: even with frame pointers disabled, > > it forces the

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

2017-09-14 Thread Linus Torvalds
On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > As it turns out, the real problem with this option is that it imposes a > penalty for CONFIG_FRAME_POINTER=n: even with frame pointers disabled, > it forces the frame pointer to be saved for each function which uses

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

2017-09-14 Thread Linus Torvalds
On Thu, Sep 14, 2017 at 7:48 AM, Josh Poimboeuf wrote: > > As it turns out, the real problem with this option is that it imposes a > penalty for CONFIG_FRAME_POINTER=n: even with frame pointers disabled, > it forces the frame pointer to be saved for each function which uses the > inline asm

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

2017-09-14 Thread Josh Poimboeuf
On Sat, Sep 02, 2017 at 12:32:21PM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > > > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This > > >mostly works for GCC, and

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

2017-09-14 Thread Josh Poimboeuf
On Sat, Sep 02, 2017 at 12:32:21PM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > > > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This > > >mostly works for GCC, and doesn't break clang.

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

2017-09-02 Thread Ingo Molnar
* Josh Poimboeuf wrote: > On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This > >mostly works for GCC, and doesn't break clang. However, it causes > >GCC to insert a "lea

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

2017-09-02 Thread Ingo Molnar
* Josh Poimboeuf wrote: > On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This > >mostly works for GCC, and doesn't break clang. However, it causes > >GCC to insert a "lea -0x10(%rbp),%rsp" in the

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

2017-08-31 Thread Josh Poimboeuf
On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This >mostly works for GCC, and doesn't break clang. However, it causes >GCC to insert a "lea -0x10(%rbp),%rsp" in the epilogue of every >affected

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

2017-08-31 Thread Josh Poimboeuf
On Thu, Aug 31, 2017 at 12:25:42PM -0500, Josh Poimboeuf wrote: > 2) Put "sp" in the clobbers list instead of as an i/o constraint. This >mostly works for GCC, and doesn't break clang. However, it causes >GCC to insert a "lea -0x10(%rbp),%rsp" in the epilogue of every >affected

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

2017-08-31 Thread Josh Poimboeuf
On Thu, Aug 31, 2017 at 09:11:54AM -0700, Linus Torvalds wrote: > On Thu, Aug 31, 2017 at 7:11 AM, Josh Poimboeuf wrote: > > > > Make the following changes: > > > > - Give alternative_io(), alternative_call(), and alternative_call_2() > > consistent interfaces. The

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

2017-08-31 Thread Josh Poimboeuf
On Thu, Aug 31, 2017 at 09:11:54AM -0700, Linus Torvalds wrote: > On Thu, Aug 31, 2017 at 7:11 AM, Josh Poimboeuf wrote: > > > > Make the following changes: > > > > - Give alternative_io(), alternative_call(), and alternative_call_2() > > consistent interfaces. The constraints are provided by

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

2017-08-31 Thread Linus Torvalds
On Thu, Aug 31, 2017 at 7:11 AM, Josh Poimboeuf wrote: > > Make the following changes: > > - Give alternative_io(), alternative_call(), and alternative_call_2() > consistent interfaces. The constraints are provided by use of the > OUTPUTS(), INPUTS(), and CLOBBERS()

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

2017-08-31 Thread Linus Torvalds
On Thu, Aug 31, 2017 at 7:11 AM, Josh Poimboeuf wrote: > > Make the following changes: > > - Give alternative_io(), alternative_call(), and alternative_call_2() > consistent interfaces. The constraints are provided by use of the > OUTPUTS(), INPUTS(), and CLOBBERS() macros. I really think

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

2017-08-31 Thread Josh Poimboeuf
The alternative code has some macros which are used for wrapping inline asm statements. These macros can be confusing: - Some of them require the caller to start their positional operands at '%1' instead of '%0'. - There are multiple variants of the macros which basically do the same thing,

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

2017-08-31 Thread Josh Poimboeuf
The alternative code has some macros which are used for wrapping inline asm statements. These macros can be confusing: - Some of them require the caller to start their positional operands at '%1' instead of '%0'. - There are multiple variants of the macros which basically do the same thing,