public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will.deacon@arm.com>
Cc: Waiman Long <longman@redhat.com>, 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>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>
Subject: Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs
Date: Mon, 21 Aug 2017 21:42:46 +0200	[thread overview]
Message-ID: <20170821194246.GA32112@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20170821192550.3dbj3jbgl33v2eeg@hirez.programming.kicks-ass.net>

On Mon, Aug 21, 2017 at 09:25:50PM +0200, Peter Zijlstra wrote:
> On Mon, Aug 21, 2017 at 07:00:02PM +0100, Will Deacon wrote:
> > > No, I meant _from_ the LL load, not _to_ a later load.
> > 
> > Sorry, I'm still not following enough to give you a definitive answer on
> > that. Could you give an example, please? These sequences usually run in
> > a loop, so the conditional branch back (based on the status flag) is where
> > the read-after-read comes in.
> > 
> > Any control dependencies from the loaded data exist regardless of the status
> > flag.
> 
> Basically what Waiman ended up doing, something like:
> 
>         if (cmpxchg_relaxed(&pn->state, vcpu_halted, vcpu_hashed) != vcpu_halted)
>                 return;
> 
>         WRITE_ONCE(l->locked, _Q_SLOW_VAL);
> 
> Where the STORE depends on the LL value being 'complete'.
> 
> 
> For any RmW we can only create a control dependency from the LOAD. The
> the same could be done for something like:
> 
> 	if (atomic_inc_not_zero(&obj->refs))
> 		WRITE_ONCE(obj->foo, 1);

Obviously I meant the hypothetical atomic_inc_not_zero_relaxed() here,
otherwise all the implied smp_mb() spoil the game.

> Where we only do the STORE if we acquire the reference. While the
> WRITE_ONCE() will not be ordered against the increment, it is ordered
> against the LL and we know it must not be 0.
> 
> Per the LL/SC loop we'll have observed a !0 value and committed the SC
> (which need not be visible or ordered against any later store) but both
> STORES (SC and the WRITE_ONCE) must be after the ->refs LOAD.

  reply	other threads:[~2017-08-21 19:42 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
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 [this message]
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=20170821194246.GA32112@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --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=paulmck@linux.vnet.ibm.com \
    --cc=will.deacon@arm.com \
    --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