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


Groups > linux.kernel > #1425258

Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier

From Will Deacon <will.deacon@arm.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier
Date 2016-06-17 17:50 +0200
Message-ID <rL4bU-8nW-33@gated-at.bofh.it> (permalink)
References (3 earlier) <rKv4u-2mG-7@gated-at.bofh.it> <rKv4u-2mG-5@gated-at.bofh.it> <rKQ8V-7Ix-5@gated-at.bofh.it> <rKQ8V-7Ix-3@gated-at.bofh.it> <rL4bU-8nW-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jun 17, 2016 at 11:26:41AM -0400, Waiman Long wrote:
> On 06/16/2016 08:48 PM, Boqun Feng wrote:
> >On Thu, Jun 16, 2016 at 05:35:54PM -0400, Waiman Long wrote:
> >>If you look into the actual code:
> >>
> >>         next = xchg_release(&node->next, NULL);
> >>         if (next) {
> >>                 WRITE_ONCE(next->locked, 1);
> >>                 return;
> >>         }
> >>
> >>There is a control dependency that WRITE_ONCE() won't happen until
> >But a control dependency only orders LOAD->STORE pairs, right? And here
> >the control dependency orders the LOAD part of xchg_release() and the
> >WRITE_ONCE().
> >
> >Along with the fact that RELEASE only orders the STORE part of xchg with
> >the memory operations preceding the STORE part, so for the following
> >code:
> >
> >	WRTIE_ONCE(x,1);
> >	next = xchg_release(&node->next, NULL);
> >	if (next)
> >		WRITE_ONCE(next->locked, 1);
> >
> >such a reordering is allowed to happen on ARM64v8
> >
> >	next = ldxr [&node->next] // LOAD part of xchg_release()
> >
> >	if (next)
> >		WRITE_ONCE(next->locked, 1);
> >
> >	WRITE_ONCE(x,1);
> >	stlxr NULL [&node->next]  // STORE part of xchg_releae()
> >
> >Am I missing your point here?
> 
> My understanding of the release barrier is that both prior LOADs and STOREs
> can't move after the barrier. If WRITE_ONCE(x, 1) can move to below as shown
> above, it is not a real release barrier and we may need to change the
> barrier code.

You seem to be missing the point.

{READ,WRITE}_ONCE accesses appearing in program order after a release
are not externally ordered with respect to the release unless they
access the same location.

This is illustrated by Boqun's example, which shows two WRITE_ONCE
accesses being reordered before a store-release forming the write
component of an xchg_release. In both cases, WRITE_ONCE(x, 1) remains
ordered before the store-release.

Will

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


Thread

[RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper acquire/release barrier Waiman Long <Waiman.Long@hpe.com> - 2016-06-15 00:50 +0200
  Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Boqun Feng <boqun.feng@gmail.com> - 2016-06-15 10:10 +0200
    Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Peter Zijlstra <peterz@infradead.org> - 2016-06-15 19:20 +0200
    Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Boqun Feng <boqun.feng@gmail.com> - 2016-06-16 04:20 +0200
      Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Will Deacon <will.deacon@arm.com> - 2016-06-16 12:20 +0200
      Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Boqun Feng <boqun.feng@gmail.com> - 2016-06-17 02:50 +0200
        Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Will Deacon <will.deacon@arm.com> - 2016-06-17 17:50 +0200
          Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Boqun Feng <boqun.feng@gmail.com> - 2016-06-18 10:50 +0200
            Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Will Deacon <will.deacon@arm.com> - 2016-06-20 10:10 +0200
  Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-15 19:00 +0200
    Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Peter Zijlstra <peterz@infradead.org> - 2016-06-15 19:20 +0200
      Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-15 20:30 +0200
        Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Peter Zijlstra <peterz@infradead.org> - 2016-06-15 20:50 +0200
          Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-15 21:00 +0200
          Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-17 03:20 +0200
            Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-17 18:30 +0200
              Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Davidlohr Bueso <dave@stgolabs.net> - 2016-06-17 18:50 +0200
      Re: [RFC PATCH-tip v2 1/6] locking/osq: Make lock/unlock proper  acquire/release barrier Peter Zijlstra <peterz@infradead.org> - 2016-06-16 00:00 +0200

csiph-web