Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1708306
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs |
| Date | 2017-08-10 10:20 +0200 |
| Message-ID | <ucQRc-2OS-9@gated-at.bofh.it> (permalink) |
| References | <tKEG6-2V1-25@gated-at.bofh.it> <ucAMq-D4-19@gated-at.bofh.it> <ucAW6-Gt-29@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Wed, Aug 09, 2017 at 05:15:33PM +0200, Peter Zijlstra wrote:
> On Wed, Aug 09, 2017 at 05:06:03PM +0200, Peter Zijlstra wrote:
> > Now, ARM64 for instance plays funny games, it does something along the
> > lines of:
> >
> > cmpxchg(ptr, old, new)
> > {
> > do {
> > r = LL(ptr);
> > if (r != old)
> > return r; /* no barriers */
> > r = new
> > } while (SC_release(ptr, r));
> > smp_mb();
> > return r;
> > }
> >
> > Thereby ordering things relative to the store on ptr, but the load can
> > very much escape. The thinking is that if success, we must observe the
> > latest value of ptr, but even in that case the load is not ordered and
> > could happen before.
> >
> > However, since we're guaranteed to observe the latest value of ptr (on
> > success) it doesn't matter if we reordered the load, there is no newer
> > value possible.
> >
> > So heaps of tricky, but correct afaict. Will?
>
> And could not PPC do something similar:
>
> cmpxchg(ptr, old, new)
> {
> lwsync();
> dp {
> r = LL(ptr);
> if (r != old)
> return;
> r = new;
> } while (SC(ptr, r));
> sync();
> return r;
> }
>
> ?
>
> the lwsync would make it store-release on SC with similar reasoning as
> above.
>
> And lwsync allows 'stores reordered after loads', which allows the prior
> smp_store_release() to leak past.
>
> Or is the reason this doesn't work on PPC that its RCpc?
Here is an example why PPC needs a sync() before the cmpxchg():
https://marc.info/?l=linux-kernel&m=144485396224519&w=2
and Paul Mckenney's detailed explanation about why this could happen:
https://marc.info/?l=linux-kernel&m=144485909826241&w=2
(Somehow, I feel like he was answering to a similar question question as
you ask here ;-))
And I think aarch64 doesn't have a problem here because it is "(other)
multi-copy atomic". Will?
Regards,
Boqun
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Peter Zijlstra <peterz@infradead.org> - 2017-08-09 17:10 +0200
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Peter Zijlstra <peterz@infradead.org> - 2017-08-09 17:20 +0200
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Boqun Feng <boqun.feng@gmail.com> - 2017-08-10 10:20 +0200
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Peter Zijlstra <peterz@infradead.org> - 2017-08-10 11:20 +0200
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-08-10 22:50 +0200
csiph-web