public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Parri <parri.andrea@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] locking/qspinlock: Ensure node is initialised before updating prev->next
Date: Wed, 31 Jan 2018 15:11:40 +0100	[thread overview]
Message-ID: <20180131141140.GA9450@andrea> (raw)
In-Reply-To: <20180131123859.GQ2269@hirez.programming.kicks-ass.net>

On Wed, Jan 31, 2018 at 01:38:59PM +0100, Peter Zijlstra wrote:
> On Wed, Jan 31, 2018 at 12:20:46PM +0000, Will Deacon wrote:
> > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
> > index 294294c71ba4..1ebbc366a31d 100644
> > --- a/kernel/locking/qspinlock.c
> > +++ b/kernel/locking/qspinlock.c
> > @@ -408,16 +408,15 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
> >  	 */
> >  	if (old & _Q_TAIL_MASK) {
> >  		prev = decode_tail(old);
> > +
> >  		/*
> > -		 * The above xchg_tail() is also a load of @lock which generates,
> > -		 * through decode_tail(), a pointer.
> > -		 *
> > -		 * The address dependency matches the RELEASE of xchg_tail()
> > -		 * such that the access to @prev must happen after.
> > +		 * We must ensure that the stores to @node are observed before
> > +		 * the write to prev->next. The address dependency on xchg_tail
> > +		 * is not sufficient to ensure this because the read component
> > +		 * of xchg_tail is unordered with respect to the initialisation
> > +		 * of node.
> >  		 */
> > -		smp_read_barrier_depends();
> 
> Right, except you're patching old code here, please try again on a tree
> that includes commit:
> 
>   548095dea63f ("locking: Remove smp_read_barrier_depends() from queued_spin_lock_slowpath()")

BTW, which loads was/is the smp_read_barrier_depends() supposed to order? ;)

I was somehow guessing that this barrier was/is there to "order" the load
from xchg_tail() with the address-dependent loads from pv_wait_node(); is
this true? (Does Will's patch really remove the reliance on the barrier?)

  Andrea


> 
> > -
> > -		WRITE_ONCE(prev->next, node);
> > +		smp_store_release(prev->next, node);
> >  
> >  		pv_wait_node(node, prev);
> >  		arch_mcs_spin_lock_contended(&node->locked);
> > -- 
> > 2.1.4
> > 

  reply	other threads:[~2018-01-31 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31 12:20 [PATCH] locking/qspinlock: Ensure node is initialised before updating prev->next Will Deacon
2018-01-31 12:38 ` Peter Zijlstra
2018-01-31 14:11   ` Andrea Parri [this message]
2018-02-03  2:24 ` kbuild test robot
2018-02-03  2:26 ` kbuild test robot

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=20180131141140.GA9450@andrea \
    --to=parri.andrea@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.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