Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:36:20 PM PDT, Nadav Amit wrote: >h...@zytor.com wrote: > >> On May 18, 2018 12:21:00 PM PDT, Linus Torvalds > wrote: >>> On Fri, May 18, 2018 at 12:18 PM Nadav Amit >wrote: >>> Gnu ASM manual says: "Each

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:36:20 PM PDT, Nadav Amit wrote: >h...@zytor.com wrote: > >> On May 18, 2018 12:21:00 PM PDT, Linus Torvalds > wrote: >>> On Fri, May 18, 2018 at 12:18 PM Nadav Amit >wrote: >>> Gnu ASM manual says: "Each time you run as it assembles exactly one >>> source program.

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 12:21:00 PM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: >> >>> Gnu ASM manual says: "Each time you run as it assembles exactly one >> source >>> program. The source

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 12:21:00 PM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: >> >>> Gnu ASM manual says: "Each time you run as it assembles exactly one >> source >>> program. The source program is made up of one or more files.” >> >>

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:21:00 PM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: > >> Gnu ASM manual says: "Each time you run as it assembles exactly one >source >> program. The source program is made up of one or more

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:21:00 PM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: > >> Gnu ASM manual says: "Each time you run as it assembles exactly one >source >> program. The source program is made up of one or more files.” > >Ok, that counts as documentation,

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: > Gnu ASM manual says: "Each time you run as it assembles exactly one source > program. The source program is made up of one or more files.” Ok, that counts as documentation, although it's confusing as hell. Is it one source

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:18 PM Nadav Amit wrote: > Gnu ASM manual says: "Each time you run as it assembles exactly one source > program. The source program is made up of one or more files.” Ok, that counts as documentation, although it's confusing as hell. Is it one source program or multiple

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:02 PM Nadav Amit wrote: > >> I can add a -Wa,[filename.s] switch. It works, but sort of undocumented. > > Oh, if it assembles things together, then that sounds optimal. > > And yes, like hpa

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:02 PM Nadav Amit wrote: > >> I can add a -Wa,[filename.s] switch. It works, but sort of undocumented. > > Oh, if it assembles things together, then that sounds optimal. > > And yes, like hpa says, we should make sure that behavior is

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:02 PM Nadav Amit wrote: > I can add a -Wa,[filename.s] switch. It works, but sort of undocumented. Oh, if it assembles things together, then that sounds optimal. And yes, like hpa says, we should make sure that behavior is acknowledged by the GNU as

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:02 PM Nadav Amit wrote: > I can add a -Wa,[filename.s] switch. It works, but sort of undocumented. Oh, if it assembles things together, then that sounds optimal. And yes, like hpa says, we should make sure that behavior is acknowledged by the GNU as people, so that

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:02:50 PM PDT, Nadav Amit wrote: >h...@zytor.com wrote: > >> On May 18, 2018 11:50:12 AM PDT, Linus Torvalds > wrote: >>> On Fri, May 18, 2018 at 11:34 AM wrote: >>> On May 18, 2018 11:25:32 AM PDT, Linus

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 12:02:50 PM PDT, Nadav Amit wrote: >h...@zytor.com wrote: > >> On May 18, 2018 11:50:12 AM PDT, Linus Torvalds > wrote: >>> On Fri, May 18, 2018 at 11:34 AM wrote: >>> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >>> torva...@linux-foundation.org> wrote: >>>

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 11:50:12 AM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 11:34 AM wrote: >> >>> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >> torva...@linux-foundation.org> wrote: >> >>> Unfortunately

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
h...@zytor.com wrote: > On May 18, 2018 11:50:12 AM PDT, Linus Torvalds > wrote: >> On Fri, May 18, 2018 at 11:34 AM wrote: >> >>> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >> torva...@linux-foundation.org> wrote: >> >>> Unfortunately gcc doesn't guarantee that global assembly

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 11:50:12 AM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 11:34 AM wrote: > >> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >torva...@linux-foundation.org> wrote: > >> Unfortunately gcc doesn't guarantee that global

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 11:50:12 AM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 11:34 AM wrote: > >> On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < >torva...@linux-foundation.org> wrote: > >> Unfortunately gcc doesn't guarantee that global assembly inlines will >appear at the top of the

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 11:34 AM wrote: > On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < torva...@linux-foundation.org> wrote: > Unfortunately gcc doesn't guarantee that global assembly inlines will appear at the top of the file. Yeah. It really would be better to do the

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 11:34 AM wrote: > On May 18, 2018 11:25:32 AM PDT, Linus Torvalds < torva...@linux-foundation.org> wrote: > Unfortunately gcc doesn't guarantee that global assembly inlines will appear at the top of the file. Yeah. It really would be better to do the "asm version of

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 11:25:32 AM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 10:24 AM Nadav Amit wrote: > >> Will it be ok just to use a global inline asm to set an “.include” >directive >> that gas would later process? (I can probably wrap it

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread hpa
On May 18, 2018 11:25:32 AM PDT, Linus Torvalds wrote: >On Fri, May 18, 2018 at 10:24 AM Nadav Amit wrote: > >> Will it be ok just to use a global inline asm to set an “.include” >directive >> that gas would later process? (I can probably wrap it in a C macro so >it >> won’t be too disgusting)

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 10:24 AM Nadav Amit wrote: > Will it be ok just to use a global inline asm to set an “.include” directive > that gas would later process? (I can probably wrap it in a C macro so it > won’t be too disgusting) Maybe. I'd almost prefer it to be the

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 10:24 AM Nadav Amit wrote: > Will it be ok just to use a global inline asm to set an “.include” directive > that gas would later process? (I can probably wrap it in a C macro so it > won’t be too disgusting) Maybe. I'd almost prefer it to be the automatic kind of thing

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Joe Perches
On Fri, 2018-05-18 at 14:22 +, Nadav Amit wrote: > It is hard to make the code readable in C, readable in the generated asm, > and to follow the coding style imposed by checkpatch (e.g., no space between > the newline and the asm argument before it). Ignore checkpatch when you know better.

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Joe Perches
On Fri, 2018-05-18 at 14:22 +, Nadav Amit wrote: > It is hard to make the code readable in C, readable in the generated asm, > and to follow the coding style imposed by checkpatch (e.g., no space between > the newline and the asm argument before it). Ignore checkpatch when you know better.

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Boris Petkov
On May 18, 2018 6:29:59 PM GMT+02:00, Nadav Amit wrote: >Funny. I found in my mailbox that you once wrote me: "It is a dumb >idea, it >doesn't bring us anything besides some superficial readability which >you >don't really need.” How about a proper quotation with the Message-id

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Boris Petkov
On May 18, 2018 6:29:59 PM GMT+02:00, Nadav Amit wrote: >Funny. I found in my mailbox that you once wrote me: "It is a dumb >idea, it >doesn't bring us anything besides some superficial readability which >you >don't really need.” How about a proper quotation with the Message-id you're referring

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:59 AM Peter Zijlstra > wrote: > >> This is an awesome hack, but is there really nothing we can do to make >> it more readable? Esp, that global asm doing the macro definition is a >> pain to

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Linus Torvalds wrote: > On Fri, May 18, 2018 at 12:59 AM Peter Zijlstra > wrote: > >> This is an awesome hack, but is there really nothing we can do to make >> it more readable? Esp, that global asm doing the macro definition is a >> pain to read. > > I actually find that macro to be *more*

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 03:46:33PM +, Nadav Amit wrote: >> In case you didn’t read the cover-letter: the patch-set does give a 2% >> performance improvement for #PF-MADV_DONTNEED microbenchmark loop. > > I saw it but *micro*-benchmark doesn't tell me

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 03:46:33PM +, Nadav Amit wrote: >> In case you didn’t read the cover-letter: the patch-set does give a 2% >> performance improvement for #PF-MADV_DONTNEED microbenchmark loop. > > I saw it but *micro*-benchmark doesn't tell me a whole lot. If

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:59 AM Peter Zijlstra wrote: > This is an awesome hack, but is there really nothing we can do to make > it more readable? Esp, that global asm doing the macro definition is a > pain to read. I actually find that macro to be *more* legible than

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Linus Torvalds
On Fri, May 18, 2018 at 12:59 AM Peter Zijlstra wrote: > This is an awesome hack, but is there really nothing we can do to make > it more readable? Esp, that global asm doing the macro definition is a > pain to read. I actually find that macro to be *more* legible than what we do now, although

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 03:46:33PM +, Nadav Amit wrote: > In case you didn’t read the cover-letter: the patch-set does give a 2% > performance improvement for #PF-MADV_DONTNEED microbenchmark loop. I saw it but *micro*-benchmark doesn't tell me a whole lot. If that "improvement" is not

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 03:46:33PM +, Nadav Amit wrote: > In case you didn’t read the cover-letter: the patch-set does give a 2% > performance improvement for #PF-MADV_DONTNEED microbenchmark loop. I saw it but *micro*-benchmark doesn't tell me a whole lot. If that "improvement" is not

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 02:36:21PM +, Nadav Amit wrote: >> I didn’t try too hard to find more affected (micro)benchmarks, but I am >> pretty sure there are: > > So you being pretty sure there are, doesn't make me go, oh, ok, then, > this is an

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 02:36:21PM +, Nadav Amit wrote: >> I didn’t try too hard to find more affected (micro)benchmarks, but I am >> pretty sure there are: > > So you being pretty sure there are, doesn't make me go, oh, ok, then, > this is an uglification we should

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 02:36:21PM +, Nadav Amit wrote: > I didn’t try too hard to find more affected (micro)benchmarks, but I am > pretty sure there are: So you being pretty sure there are, doesn't make me go, oh, ok, then, this is an uglification we should try to live with. It is still ugly

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 02:36:21PM +, Nadav Amit wrote: > I didn’t try too hard to find more affected (micro)benchmarks, but I am > pretty sure there are: So you being pretty sure there are, doesn't make me go, oh, ok, then, this is an uglification we should try to live with. It is still ugly

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 10:13:54AM +0200, Ingo Molnar wrote: >> Yes, that's my main worry too about all these inlining changes: >> the very, very marked reduction in the readability of assembly code. > > Same reaction here: the small improvements this

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Borislav Petkov wrote: > On Fri, May 18, 2018 at 10:13:54AM +0200, Ingo Molnar wrote: >> Yes, that's my main worry too about all these inlining changes: >> the very, very marked reduction in the readability of assembly code. > > Same reaction here: the small improvements this brings is simply

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Ingo Molnar wrote: > > * Peter Zijlstra wrote: > >> On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >>> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >>> +"1:\t \\ins\n\t" >>> +".pushsection

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Ingo Molnar wrote: > > * Peter Zijlstra wrote: > >> On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >>> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >>> +"1:\t \\ins\n\t" >>> +".pushsection __bug_table,\"aw\"\n" >>> +"2:\t "__BUG_REL(1b)

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Peter Zijlstra wrote: > On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >> +"1:\t \\ins\n\t" >> +".pushsection __bug_table,\"aw\"\n" >> +"2:\t "__BUG_REL(1b)"\t#

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Nadav Amit
Peter Zijlstra wrote: > On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: >> +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" >> +"1:\t \\ins\n\t" >> +".pushsection __bug_table,\"aw\"\n" >> +"2:\t "__BUG_REL(1b)"\t#

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 10:13:54AM +0200, Ingo Molnar wrote: > Yes, that's my main worry too about all these inlining changes: > the very, very marked reduction in the readability of assembly code. Same reaction here: the small improvements this brings is simply not enough to sacrifice

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Borislav Petkov
On Fri, May 18, 2018 at 10:13:54AM +0200, Ingo Molnar wrote: > Yes, that's my main worry too about all these inlining changes: > the very, very marked reduction in the readability of assembly code. Same reaction here: the small improvements this brings is simply not enough to sacrifice

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: > > +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" > > +"1:\t \\ins\n\t" > > +".pushsection __bug_table,\"aw\"\n" > > +"2:\t "__BUG_REL(1b)

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: > > +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" > > +"1:\t \\ins\n\t" > > +".pushsection __bug_table,\"aw\"\n" > > +"2:\t "__BUG_REL(1b) "\t#

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Peter Zijlstra
On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: > +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" > +"1:\t \\ins\n\t" > +".pushsection __bug_table,\"aw\"\n" > +"2:\t "__BUG_REL(1b) "\t# bug_entry::bug_addr\n\t" > +__BUG_REL(\\file)

Re: [PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-18 Thread Peter Zijlstra
On Thu, May 17, 2018 at 09:13:58AM -0700, Nadav Amit wrote: > +asm(".macro __BUG_FLAGS ins:req file:req line:req flags:req size:req\n" > +"1:\t \\ins\n\t" > +".pushsection __bug_table,\"aw\"\n" > +"2:\t "__BUG_REL(1b) "\t# bug_entry::bug_addr\n\t" > +__BUG_REL(\\file)

[PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-17 Thread Nadav Amit
GCC considers the number of statements in inlined assembly blocks, according to new-lines and semicolons, as an indication to the cost of the block in time and space. This data is distorted by the kernel code, which puts information in alternative sections. As a result, the compiler may perform

[PATCH 2/6] x86: bug: prevent gcc distortions

2018-05-17 Thread Nadav Amit
GCC considers the number of statements in inlined assembly blocks, according to new-lines and semicolons, as an indication to the cost of the block in time and space. This data is distorted by the kernel code, which puts information in alternative sections. As a result, the compiler may perform