From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
Ingo Molnar <mingo@kernel.org>,
parri.andrea@gmail.com
Subject: Re: [RFC][PATCH] locking/mcs: Fix ordering for mcs_spin_lock()
Date: Mon, 1 Feb 2016 16:58:13 +0000 [thread overview]
Message-ID: <20160201165813.GH6828@arm.com> (raw)
In-Reply-To: <20160201143724.GW6357@twins.programming.kicks-ass.net>
Hi Peter,
On Mon, Feb 01, 2016 at 03:37:24PM +0100, Peter Zijlstra wrote:
> Given the below patch; we've now got an unconditional full global
> barrier in, does this make the MCS spinlock RCsc ?
>
> The 'problem' is that this barrier can happen before we actually acquire
> the lock. That is, if we hit arch_mcs_spin_lock_contended() _that_ will
> be the acquire barrier and we end up with a SYNC in between unlock and
> lock -- ie. not an smp_mb__after_unlock_lock() equivalent.
In which case, I don't think the lock will be RCsc with this change;
you'd need an smp_mb__after_unlock_lock() after
arch_mcs_spin_lock_contended(...) if you wanted the thing to be RCsc.
> Subject: locking/mcs: Fix ordering for mcs_spin_lock()
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Mon Feb 1 15:11:28 CET 2016
>
> Similar to commit b4b29f94856a ("locking/osq: Fix ordering of node
> initialisation in osq_lock") the use of xchg_acquire() is
> fundamentally broken with MCS like constructs.
>
> Furthermore, it turns out we rely on the global transitivity of this
> operation because the unlock path observes the pointer with a
> READ_ONCE(), not an smp_load_acquire().
>
> This is non-critical because the MCS code isn't actually used and
> mostly serves as documentation, a stepping stone to the more complex
> things we've build on top of the idea.
>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Reported-by: Andrea Parri <parri.andrea@gmail.com>
> Fixes: 3552a07a9c4a ("locking/mcs: Use acquire/release semantics")
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/locking/mcs_spinlock.h | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
Acked-by: Will Deacon <will.deacon@arm.com>
Although I wonder how useful this is as a documentation aid now that we
have the osq_lock.
Will
next prev parent reply other threads:[~2016-02-01 16:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-01 14:37 [RFC][PATCH] locking/mcs: Fix ordering for mcs_spin_lock() Peter Zijlstra
2016-02-01 16:58 ` Will Deacon [this message]
2016-02-01 17:24 ` Peter Zijlstra
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=20160201165813.GH6828@arm.com \
--to=will.deacon@arm.com \
--cc=dave@stgolabs.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=parri.andrea@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.