Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1585283
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs |
| Date | 2017-02-21 14:10 +0100 |
| Message-ID | <tdimB-30G-15@gated-at.bofh.it> (permalink) |
| References | <tbXDA-DC-3@gated-at.bofh.it> <tcNLP-8g1-3@gated-at.bofh.it> <tcOeR-8pV-1@gated-at.bofh.it> <tcOeX-8pV-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Feb 20, 2017 at 12:58:39PM +0800, Boqun Feng wrote:
> > So Waiman, the fact is that in this case, we want the following code
> > sequence:
> >
> > CPU 0 CPU 1
> > ================= ====================
> > {pn->state = vcpu_running, node->locked = 0}
> >
> > smp_store_smb(&pn->state, vcpu_halted):
> > WRITE_ONCE(pn->state, vcpu_halted);
> > smp_mb();
> > r1 = READ_ONCE(node->locked);
> > arch_mcs_spin_unlock_contented();
> > WRITE_ONCE(node->locked, 1)
> >
> > cmpxchg(&pn->state, vcpu_halted, vcpu_hashed);
> >
> > never ends up in:
> >
> > r1 == 0 && cmpxchg fail(i.e. the read part of cmpxchg reads the
> > value vcpu_running).
> >
> > We can have such a guarantee if cmpxchg has a smp_mb() before its load
> > part, which is true for PPC. But semantically, cmpxchg() doesn't provide
> > any order guarantee if it fails, which is true on ARM64, IIUC. (Add Will
> > in Cc for his insight ;-)).
I think you're right. The write to node->locked on CPU1 is not required
to be ordered before the load part of the failing cmpxchg.
> > So a possible "fix"(in case ARM64 will use qspinlock some day), would be
> > replace cmpxchg() with smp_mb() + cmpxchg_relaxed().
Peversely, we could actually get away with cmpxchg_acquire on arm64 because
arch_mcs_spin_unlock_contended is smp_store_release and we order release ->
acquire in the architecture. But that just brings up the age old unlock/lock
discussion again...
Will
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Waiman Long <longman@redhat.com> - 2017-02-17 21:50 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Andrea Parri <parri.andrea@gmail.com> - 2017-02-20 05:30 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Boqun Feng <boqun.feng@gmail.com> - 2017-02-20 06:00 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Boqun Feng <boqun.feng@gmail.com> - 2017-02-20 06:00 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Will Deacon <will.deacon@arm.com> - 2017-02-21 14:10 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Waiman Long <longman@redhat.com> - 2017-02-20 17:00 +0100
Re: [PATCH v3] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Peter Zijlstra <peterz@infradead.org> - 2017-02-20 12:10 +0100
csiph-web