mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: 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: Thu, 10 Aug 2017 09:58:57 -0400	[thread overview]
Message-ID: <e5c69658-c5d5-5171-86ed-7716d8d1eedd@redhat.com> (raw)
In-Reply-To: <945c28c3-5779-c8c8-13bb-40477abd1f0e@redhat.com>

On 08/10/2017 09:27 AM, Waiman Long wrote:
> On 08/10/2017 07:50 AM, Peter Zijlstra wrote:
>> On Wed, May 24, 2017 at 09:38:28AM -0400, Waiman Long wrote:
>>>   # of thread     w/o patch    with patch      % Change
>>>   -----------     ---------    ----------      --------
>>>        4         4053.3 Mop/s  4223.7 Mop/s     +4.2%
>>>        8         3310.4 Mop/s  3406.0 Mop/s     +2.9%
>>>       12         2576.4 Mop/s  2674.6 Mop/s     +3.8%
>> Waiman, could you run those numbers again but with the below 'fixed' ?
>>
>>> @@ -361,6 +361,13 @@ static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node)
>>>  	 * observe its next->locked value and advance itself.
>>>  	 *
>>>  	 * Matches with smp_store_mb() and cmpxchg() in pv_wait_node()
>>> +	 *
>>> +	 * The write to next->locked in arch_mcs_spin_unlock_contended()
>>> +	 * must be ordered before the read of pn->state in the cmpxchg()
>>> +	 * below for the code to work correctly. However, this is not
>>> +	 * guaranteed on all architectures when the cmpxchg() call fails.
>>> +	 * Both x86 and PPC can provide that guarantee, but other
>>> +	 * architectures not necessarily.
>>>  	 */
>> 	smp_mb();
>>
>>>  	if (cmpxchg(&pn->state, vcpu_halted, vcpu_hashed) != vcpu_halted)
>>>  		return;
>> Ideally this Power CPU can optimize back-to-back SYNC instructions, but
>> who knows...
> Yes, I can run the numbers again. However, the changes here is in the
> slowpath. My current patch optimizes the fast path only and my original
> test doesn't stress the slowpath at all, I think. I will have to make
> some changes to stress the slowpath.

Looking at past emails, I remember why I put the comment there. Putting
an smp_mb() here will definitely has an negative performance impact on
x86. So I put in the comment here to remind me that the current code may
not work for ARM64.

To fix that, my current thought is to have a cmpxchg variant that
guarantees ordering for both success and failure, for example,
cmpxchg_ordered(). In that way, we only need to insert the barrier for
architectures that need it. That will be a separate patch instead of
integrating into this one.

Cheers,
Longman

  reply	other threads:[~2017-08-10 13:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 13:38 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 [this message]
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
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=e5c69658-c5d5-5171-86ed-7716d8d1eedd@redhat.com \
    --to=longman@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®