From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>,
linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
manfred@colorfullife.com, dave@stgolabs.net,
paulmck@linux.vnet.ibm.com, Waiman.Long@hpe.com, tj@kernel.org,
pablo@netfilter.org, kaber@trash.net, davem@davemloft.net,
oleg@redhat.com, netfilter-devel@vger.kernel.org,
sasha.levin@oracle.com, hofrat@osadl.org, jejb@parisc-linux.org,
chris@zankel.net, rth@twiddle.net, dhowells@redhat.com,
schwidefsky@de.ibm.com, mpe@ellerman.id.au, ralf@linux-mips.org,
linux@armlinux.org.uk, rkuo@codeaurora.org, vgupta@synopsys.com,
james.hogan@imgtec.com, realmz6@gmail.com,
ysato@users.sourceforge.jp, tony.luck@intel.com,
cmetcalf@mellanox.com
Subject: Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait()
Date: Thu, 2 Jun 2016 18:57:00 +0100 [thread overview]
Message-ID: <20160602175659.GB7697@arm.com> (raw)
In-Reply-To: <20160602163425.GV3205@twins.programming.kicks-ass.net>
On Thu, Jun 02, 2016 at 06:34:25PM +0200, Peter Zijlstra wrote:
> On Thu, Jun 02, 2016 at 04:44:24PM +0200, Peter Zijlstra wrote:
> > On Thu, Jun 02, 2016 at 10:24:40PM +0800, Boqun Feng wrote:
> > > On Thu, Jun 02, 2016 at 01:52:02PM +0200, Peter Zijlstra wrote:
> > > About spin_unlock_wait() on ppc, I actually have a fix pending review:
> > >
> > > http://lkml.kernel.org/r/1461130033-70898-1-git-send-email-boqun.feng@gmail.com
> >
> > > that patch fixed a different problem when people want to pair a
> > > spin_unlock_wait() with a spin_lock().
> >
> > Argh, indeed, and I think qspinlock is still broken there :/ But my poor
> > brain is about to give in for the day.
>
> This 'replaces' commit:
>
> 54cf809b9512 ("locking,qspinlock: Fix spin_is_locked() and spin_unlock_wait()")
>
> and seems to still work with the test case from that thread while
> getting rid of the extra barriers.
>
> ---
> include/asm-generic/qspinlock.h | 37 +++++++----------------------------
> kernel/locking/qspinlock.c | 43 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 50 insertions(+), 30 deletions(-)
>
> diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
> index 6bd05700d8c9..9e3dff16d5dc 100644
> --- a/include/asm-generic/qspinlock.h
> +++ b/include/asm-generic/qspinlock.h
> @@ -28,30 +28,13 @@
> */
> static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
> {
> - /*
> - * queued_spin_lock_slowpath() can ACQUIRE the lock before
> - * issuing the unordered store that sets _Q_LOCKED_VAL.
> - *
> - * See both smp_cond_acquire() sites for more detail.
> - *
> - * This however means that in code like:
> - *
> - * spin_lock(A) spin_lock(B)
> - * spin_unlock_wait(B) spin_is_locked(A)
> - * do_something() do_something()
> + /*
> + * See queued_spin_unlock_wait().
> *
> - * Both CPUs can end up running do_something() because the store
> - * setting _Q_LOCKED_VAL will pass through the loads in
> - * spin_unlock_wait() and/or spin_is_locked().
> - *
> - * Avoid this by issuing a full memory barrier between the spin_lock()
> - * and the loads in spin_unlock_wait() and spin_is_locked().
> - *
> - * Note that regular mutual exclusion doesn't care about this
> - * delayed store.
> + * Any !0 state indicates it is locked, even if _Q_LOCKED_VAL
> + * isn't immediately observable.
> */
> - smp_mb();
> - return atomic_read(&lock->val) & _Q_LOCKED_MASK;
> + return !!atomic_read(&lock->val);
> }
I'm failing to keep up here :(
The fast-path code in queued_spin_lock is just an atomic_cmpxchg_acquire.
If that's built out of LL/SC instructions, then why don't we need a barrier
here in queued_spin_is_locked?
Or is the decision now that only spin_unlock_wait is required to enforce
this ordering?
Will
next prev parent reply other threads:[~2016-06-02 17:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 11:51 [PATCH -v4 0/7] spin_unlock_wait borkage and assorted bits Peter Zijlstra
2016-06-02 11:51 ` [PATCH -v4 1/7] locking: Replace smp_cond_acquire with smp_cond_load_acquire Peter Zijlstra
2016-06-02 11:51 ` [PATCH -v4 2/7] locking: Introduce smp_acquire__after_ctrl_dep Peter Zijlstra
2016-06-02 11:52 ` [PATCH -v4 3/7] locking: Move smp_cond_load_acquire() to asm-generic/barrier.h Peter Zijlstra
2016-06-02 11:52 ` [PATCH -v4 4/7] locking, tile: Provide TILE specific smp_acquire__after_ctrl_dep Peter Zijlstra
2016-06-02 11:52 ` [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra
2016-06-02 14:24 ` Boqun Feng
2016-06-02 14:44 ` Peter Zijlstra
2016-06-02 15:11 ` Boqun Feng
2016-06-02 15:57 ` Boqun Feng
2016-06-02 16:04 ` Peter Zijlstra
2016-06-02 16:34 ` Peter Zijlstra
2016-06-02 17:57 ` Will Deacon [this message]
2016-06-02 21:51 ` Peter Zijlstra
2016-06-03 12:47 ` Will Deacon
2016-06-03 13:42 ` Peter Zijlstra
2016-06-03 17:35 ` Will Deacon
2016-06-03 19:13 ` Peter Zijlstra
2016-06-03 13:48 ` Peter Zijlstra
2016-06-06 16:08 ` Peter Zijlstra
2016-06-07 11:43 ` Boqun Feng
2016-06-07 12:00 ` Peter Zijlstra
2016-06-07 12:45 ` Boqun Feng
2016-06-07 17:36 ` Peter Zijlstra
2016-06-02 11:52 ` [PATCH -v4 6/7] locking: Update spin_unlock_wait users Peter Zijlstra
2016-06-02 11:52 ` [PATCH -v4 7/7] locking,netfilter: Fix nf_conntrack_lock() Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160602175659.GB7697@arm.com \
--to=will.deacon@arm.com \
--cc=Waiman.Long@hpe.com \
--cc=boqun.feng@gmail.com \
--cc=chris@zankel.net \
--cc=cmetcalf@mellanox.com \
--cc=dave@stgolabs.net \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=hofrat@osadl.org \
--cc=james.hogan@imgtec.com \
--cc=jejb@parisc-linux.org \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=manfred@colorfullife.com \
--cc=mpe@ellerman.id.au \
--cc=netfilter-devel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=pablo@netfilter.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
--cc=realmz6@gmail.com \
--cc=rkuo@codeaurora.org \
--cc=rth@twiddle.net \
--cc=sasha.levin@oracle.com \
--cc=schwidefsky@de.ibm.com \
--cc=tj@kernel.org \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=vgupta@synopsys.com \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).