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


Groups > linux.kernel > #1307875

Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb()

From "Michael S. Tsirkin" <mst@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb()
Date 2016-01-12 23:20 +0100
Message-ID <qQfse-7eN-19@gated-at.bofh.it> (permalink)
References (5 earlier) <qQaVC-40U-53@gated-at.bofh.it> <qQdTs-65I-5@gated-at.bofh.it> <qQecO-6d2-21@gated-at.bofh.it> <qQemu-6vy-7@gated-at.bofh.it> <qQePw-6Hn-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Jan 12, 2016 at 01:37:38PM -0800, Linus Torvalds wrote:
> On Tue, Jan 12, 2016 at 12:59 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> >
> > Here's an article with numbers:
> >
> > http://shipilev.net/blog/2014/on-the-fence-with-dependencies/
> 
> Well, that's with the busy loop and one set of code generation. It
> doesn't show the "oops, deeper stack isn't even in the cache any more
> due to call chains" issue.
> 
> But yes:
> 
> > I think they're suggesting using a negative offset, which is safe as
> > long as it doesn't page fault, even though we have the redzone
> > disabled.
> 
> I think a negative offset might work very well. Partly exactly
> *because* we have the redzone disabled: we know that inside the
> kernel, we'll never have any live stack frame accesses under the stack
> pointer, so "-4(%rsp)" sounds good to me. There should never be any
> pending writes in the write buffer, because even if it *was* live, it
> would have been read off first.
> 
> Yeah, it potentially does extend the stack cache footprint by another
> 4 bytes, but that sounds very benign.
> 
> So perhaps it might be worth trying to switch the "mfence" to "lock ;
> addl $0,-4(%rsp)" in the kernel for x86-64, and remove the alternate
> for x86-32.
> 
> I'd still want to see somebody try to benchmark it. I doubt it's
> noticeable, but making changes because you think it might save a few
> cycles without then even measuring it is just wrong.
> 
>                  Linus

Oops, I posted v2 with just offset 0 before reading
the rest of this thread.
I did try with offset 0 and didn't measure any
change on any perf bench test, or on kernel build.
I wonder which benchmark stresses smp_mb the most.
I'll look into using a negative offset.

-- 
MST

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


Thread

Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-12 15:00 +0100
  Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 18:30 +0100
    Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-12 18:50 +0100
      Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 19:10 +0100
    Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Andy Lutomirski <luto@kernel.org> - 2016-01-12 21:40 +0100
      Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 22:00 +0100
        Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Andy Lutomirski <luto@amacapital.net> - 2016-01-12 22:10 +0100
          Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-12 22:40 +0100
            Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-12 23:20 +0100
            Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-13 17:30 +0100
          Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-12 23:30 +0100
            Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "H. Peter Anvin" <hpa@zytor.com> - 2016-01-13 00:00 +0100
              Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-13 00:30 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Borislav Petkov <bp@alien8.de> - 2016-01-13 17:20 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-13 17:30 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Borislav Petkov <bp@alien8.de> - 2016-01-13 17:40 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-13 17:50 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Borislav Petkov <bp@alien8.de> - 2016-01-13 18:00 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() "Michael S. Tsirkin" <mst@redhat.com> - 2016-01-13 18:10 +0100
                Re: [PATCH 3/4] x86,asm: Re-work smp_store_mb() Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-13 19:40 +0100

csiph-web