From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <waiman.long@hpe.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Scott J Norton <scott.norton@hpe.com>,
Douglas Hatch <doug.hatch@hpe.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Will Deacon <will.deacon@arm.com>,
Paul McKenney <paulmck@linux.vnet.ibm.com>,
boqun.feng@gmail.com
Subject: Re: [PATCH v7 1/5] locking/qspinlock: relaxes cmpxchg & xchg ops in native code
Date: Tue, 13 Oct 2015 22:47:52 +0200 [thread overview]
Message-ID: <20151013204752.GO17308@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <561D6BBB.6070706@hpe.com>
On Tue, Oct 13, 2015 at 04:38:19PM -0400, Waiman Long wrote:
> On 10/13/2015 02:02 PM, Peter Zijlstra wrote:
> >On Tue, Sep 22, 2015 at 04:50:40PM -0400, Waiman Long wrote:
> >>This patch replaces the cmpxchg() and xchg() calls in the native
> >>qspinlock code with more relaxed versions of those calls to enable
> >>other architectures to adopt queued spinlocks with less performance
> >>overhead.
> >>@@ -62,7 +63,7 @@ static __always_inline int queued_spin_is_contended(struct qspinlock *lock)
> >> static __always_inline int queued_spin_trylock(struct qspinlock *lock)
> >> {
> >> if (!atomic_read(&lock->val)&&
> >>- (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) == 0))
> >>+ (atomic_cmpxchg_acquire(&lock->val, 0, _Q_LOCKED_VAL) == 0))
> >> return 1;
> >> return 0;
> >> }
> >>@@ -77,7 +78,7 @@ static __always_inline void queued_spin_lock(struct qspinlock *lock)
> >> {
> >> u32 val;
> >>
> >>- val = atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL);
> >>+ val = atomic_cmpxchg_acquire(&lock->val, 0, _Q_LOCKED_VAL);
> >> if (likely(val == 0))
> >> return;
> >> queued_spin_lock_slowpath(lock, val);
> >>@@ -319,7 +329,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
> >> if (val == new)
> >> new |= _Q_PENDING_VAL;
> >>
> >>- old = atomic_cmpxchg(&lock->val, val, new);
> >>+ old = atomic_cmpxchg_acquire(&lock->val, val, new);
> >> if (old == val)
> >> break;
> >>
> >So given recent discussion, all this _release/_acquire stuff is starting
> >to worry me.
> >
> >So we've not declared if they should be RCsc or RCpc, and given this
> >patch (and the previous ones) these lock primitives turn into RCpc if
> >the atomic primitives are RCpc.
> >
> >So far only the proposed PPC implementation is RCpc -- and their current
> >spinlock implementation is also RCpc, but that is a point of discussion.
> >
> >Just saying..
>
> Davidlohr's patches to make similar changes in other locking code will also
> have this issue.
Yes, I only fully appreciated the RCpc pain last week :/
> Anyway, the goal of this patch is to make the generic
> qspinlock code less costly when ported to other architectures.
As long as we stay away from PPC this will be fine ;-) Luckily they are
unlikely to start using it since their LPAR hypervisor thingy isn't
really co-operative.
> This change
> will have no effect on the x86 architecture which is the only one using
I know ARM and ARGH64 will want to start using this, luckily both are
RCsc so no worries there.
next prev parent reply other threads:[~2015-10-13 20:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 20:50 [PATCH v7 0/5] locking/qspinlock: Enhance pvqspinlock performance Waiman Long
2015-09-22 20:50 ` [PATCH v7 1/5] locking/qspinlock: relaxes cmpxchg & xchg ops in native code Waiman Long
2015-10-13 18:02 ` Peter Zijlstra
2015-10-13 20:38 ` Waiman Long
2015-10-13 20:47 ` Peter Zijlstra [this message]
2015-10-14 9:39 ` Will Deacon
2015-09-22 20:50 ` [PATCH v7 2/5] locking/pvqspinlock, x86: Optimize PV unlock code path Waiman Long
2015-09-22 20:50 ` [PATCH v7 3/5] locking/pvqspinlock: Collect slowpath lock statistics Waiman Long
2015-10-13 20:05 ` Peter Zijlstra
2015-10-13 21:06 ` Waiman Long
2015-09-22 20:50 ` [PATCH v7 4/5] locking/pvqspinlock: Allow 1 lock stealing attempt Waiman Long
2015-10-13 18:23 ` Peter Zijlstra
2015-10-13 20:41 ` Waiman Long
2015-10-13 20:44 ` Peter Zijlstra
2015-10-15 20:44 ` Waiman Long
2015-10-13 19:39 ` Peter Zijlstra
2015-10-13 20:45 ` Waiman Long
2015-10-13 19:56 ` Peter Zijlstra
2015-10-13 20:50 ` Waiman Long
2015-10-14 9:28 ` Peter Zijlstra
2015-10-15 21:01 ` Waiman Long
2015-09-22 20:50 ` [PATCH v7 5/5] locking/pvqspinlock: Queue node adaptive spinning Waiman Long
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=20151013204752.GO17308@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=boqun.feng@gmail.com \
--cc=dave@stgolabs.net \
--cc=doug.hatch@hpe.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=waiman.long@hpe.com \
--cc=will.deacon@arm.com \
--cc=x86@kernel.org \
/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
Powered by JetHome