Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1412468
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() |
| Date | 2016-06-02 20:00 +0200 |
| Message-ID | <rFF4t-HB-13@gated-at.bofh.it> (permalink) |
| References | <rFzs5-5tU-7@gated-at.bofh.it> <rFzs6-5tU-37@gated-at.bofh.it> <rFBNg-71V-43@gated-at.bofh.it> <rFC6B-78u-5@gated-at.bofh.it> <rFDP3-8ex-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-02 14:00 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Boqun Feng <boqun.feng@gmail.com> - 2016-06-02 16:30 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-02 16:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Boqun Feng <boqun.feng@gmail.com> - 2016-06-02 17:10 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Boqun Feng <boqun.feng@gmail.com> - 2016-06-02 18:00 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-02 18:10 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-02 18:40 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Will Deacon <will.deacon@arm.com> - 2016-06-02 20:00 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-03 00:00 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Will Deacon <will.deacon@arm.com> - 2016-06-03 14:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-03 15:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Will Deacon <will.deacon@arm.com> - 2016-06-03 19:40 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-03 21:20 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-03 15:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-06 18:10 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Boqun Feng <boqun.feng@gmail.com> - 2016-06-07 13:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-07 14:10 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Boqun Feng <boqun.feng@gmail.com> - 2016-06-07 14:50 +0200
Re: [PATCH -v4 5/7] locking, arch: Update spin_unlock_wait() Peter Zijlstra <peterz@infradead.org> - 2016-06-07 19:40 +0200
csiph-web