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


Groups > linux.kernel > #1547373

Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit

From Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit
Date 2016-12-26 20:10 +0100
Message-ID <sSIOJ-ee-3@gated-at.bofh.it> (permalink)
References <sS7m9-7cV-3@gated-at.bofh.it> <sS7m9-7cV-1@gated-at.bofh.it> <sSoZH-3cN-5@gated-at.bofh.it> <sSs7f-5Sm-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Dec 25, 2016 at 5:16 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> I did actually play around with that. I could not get my skylake
> to forward the result from a lock op to a subsequent load (the
> latency was the same whether you use lock ; andb or lock ; andl
> (32 cycles for my test loop) whereas with non-atomic versions I
> was getting about 15 cycles for andb vs 2 for andl.

Yes, interesting. It does look like the locked ops don't end up having
the partial write issue and the size of the op doesn't matter.

But it's definitely the case that the write buffer hit immediately
after the atomic read-modify-write ends up slowing things down, so the
profile oddity isn't just a profile artifact. I wrote a stupid test
program that did an atomic increment, and then read either the same
value, or an adjacent value in memory (so same instruvtion sequence,
the difference just being what memory location the read accessed).

Reading the same value after the atomic update was *much* more
expensive than reading the adjacent value, so it causes some kind of
pipeline hickup (by about 50% of the cost of the atomic op itself:
iow, the "atomic-op followed by read same location" was over 1.5x
slower than "atomic op followed by read of another location").

So the atomic ops don't serialize things entirely, but they *hate*
having the value read (regardless of size) right after being updated,
because it causes some kind of nasty pipeline issue.

A cmpxchg does seem to avoid the issue.

             Linus

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


Thread

[PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-25 04:10 +0100
  Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-25 23:00 +0100
    Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-26 02:20 +0100
      Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-26 20:10 +0100
        Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-27 12:30 +0100
          Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-27 20:00 +0100
            Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-27 20:40 +0100
              Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-27 20:50 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-27 21:20 +0100
            Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-27 20:40 +0100
            Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-28 05:00 +0100
              Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-29 05:10 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-29 05:20 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2016-12-29 06:30 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Mel Gorman <mgorman@techsingularity.net> - 2017-01-03 11:30 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting  for a page bit Nicholas Piggin <npiggin@gmail.com> - 2017-01-03 13:40 +0100
                Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Mel Gorman <mgorman@techsingularity.net> - 2017-01-03 18:20 +0100
                [PATCH] mm/filemap: fix parameters to test_bit() Olof Johansson <olof@lixom.net> - 2016-12-29 23:20 +0100
              Re: [PATCH 2/2] mm: add PageWaiters indicating tasks are waiting for  a page bit Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-28 20:20 +0100

csiph-web