From: Will Deacon <will.deacon@arm.com>
To: Waiman Long <longman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Pan Xinhui <xinhui@linux.vnet.ibm.com>,
Boqun Feng <boqun.feng@gmail.com>,
Andrea Parri <parri.andrea@gmail.com>
Subject: Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs
Date: Mon, 14 Aug 2017 17:02:02 +0100 [thread overview]
Message-ID: <20170814160202.GB27527@arm.com> (raw)
In-Reply-To: <b1f9844e-60a9-a071-4cfc-831b66219519@redhat.com>
On Mon, Aug 14, 2017 at 11:01:10AM -0400, Waiman Long wrote:
> On 08/14/2017 08:01 AM, Will Deacon wrote:
> > On Fri, Aug 11, 2017 at 11:06:01AM +0200, Peter Zijlstra wrote:
> >> On Thu, Aug 10, 2017 at 02:18:30PM -0400, Waiman Long wrote:
> >>> On 08/10/2017 12:22 PM, Waiman Long wrote:
> >>>> On 08/10/2017 12:15 PM, Peter Zijlstra wrote:
> >>>>> Might as well do an explicit:
> >>>>>
> >>>>> smp_mb__before_atomic()
> >>>>> cmpxchg_relaxed()
> >>>>> smp_mb__after_atomic()
> >>>>>
> >>>>> I suppose and not introduce new primitives.
> >>> I think we don't need smp_mb__after_atomic(). The read has to be fully
> >>> ordered, but the write part may not need it as the control dependency of
> >>> the old value should guard against incorrect action. Right?
> >> You'd think that, but IIRC there was something funny about using the SC
> >> return flag for control dependencies. Will?
> > Yeah, that's right, you can't use the STXR status flag to create control
> > dependencies.
> >
> > Will
>
> Actually, the code sequence that I plan to use are:
>
> smp_mb__before_atomic();
> if (cmpxchg_relaxed(&pn->state, vcpu_halted, vcpu_hashed)
> != vcpu_halted)
> return;
>
> WRITE_ONCE(l->locked, _Q_SLOW_VAL);
> (void)pv_hash(lock, pn);
>
> I am planning to use the comparison of the returned value (pn->state)
> again vcpu_halted as the control dependency. I don't see how the status
> flag of STXR is affecting this.
Thanks for the context. I agree that you've got a control dependency in this
case, so the WRITE_ONCE will be ordered after the LL part of the cmpxchg. It
could still be reordered with respect to the write part, however.
Will
next prev parent reply other threads:[~2017-08-14 16:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 13:38 [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs Waiman Long
2017-08-09 13:39 ` Waiman Long
2017-08-09 15:06 ` Peter Zijlstra
2017-08-09 15:15 ` Peter Zijlstra
2017-08-10 8:12 ` Boqun Feng
2017-08-10 9:13 ` Peter Zijlstra
2017-08-10 20:49 ` Paul E. McKenney
2017-08-10 11:50 ` Peter Zijlstra
2017-08-10 13:27 ` Waiman Long
2017-08-10 13:58 ` Waiman Long
2017-08-10 16:15 ` Peter Zijlstra
2017-08-10 16:22 ` Waiman Long
2017-08-10 18:18 ` Waiman Long
2017-08-11 9:06 ` Peter Zijlstra
2017-08-14 12:01 ` Will Deacon
2017-08-14 15:01 ` Waiman Long
2017-08-14 16:02 ` Will Deacon [this message]
2017-08-14 18:47 ` Peter Zijlstra
2017-08-15 18:40 ` Will Deacon
2017-08-21 10:55 ` Peter Zijlstra
2017-08-21 18:00 ` Will Deacon
2017-08-21 19:25 ` Peter Zijlstra
2017-08-21 19:42 ` Peter Zijlstra
2017-08-22 15:35 ` Waiman Long
2017-08-22 10:40 ` Will Deacon
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=20170814160202.GB27527@arm.com \
--to=will.deacon@arm.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=parri.andrea@gmail.com \
--cc=peterz@infradead.org \
--cc=xinhui@linux.vnet.ibm.com \
/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