public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <waiman.long@hp.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, Jason Low <jason.low2@hp.com>,
	Scott J Norton <scott.norton@hp.com>,
	Douglas Hatch <doug.hatch@hp.com>
Subject: Re: [PATCH] locking/rwsem: reduce spinlock contention in wakeup after up_read/up_write
Date: Thu, 23 Apr 2015 14:41:29 -0400	[thread overview]
Message-ID: <55393CD9.2060703@hp.com> (raw)
In-Reply-To: <20150418154014.GV27490@worktop.programming.kicks-ass.net>

On 04/18/2015 11:40 AM, Peter Zijlstra wrote:
> On Fri, Apr 17, 2015 at 10:03:18PM -0400, Waiman Long wrote:
>> @@ -478,7 +515,28 @@ struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem)
>>   {
>>   	unsigned long flags;
>>
>> -	raw_spin_lock_irqsave(&sem->wait_lock, flags);
>> +	/*
>> +	 * If a spinner is present, it is not necessary to do the wakeup.
>> +	 * Try to do wakeup only if the trylock succeeds to minimize
>> +	 * spinlock contention which may introduce too much delay in the
>> +	 * unlock operation.
>> +	 *
>> +	 * In case the spinning writer is just going to break out of the
>> +	 * waiting loop, it will still do a trylock in
>> +	 * rwsem_down_write_failed() before sleeping.
>> +	 * IOW, if rwsem_has_spinner() is true, it will guarantee at least
>> +	 * one trylock attempt on the rwsem.
> successful trylock? I think we're having 'issues' on if failed trylocks
> (and cmpxchg) imply full barriers.
>
>> +	 *
>> +	 *    spinning writer
>> +	 *    ---------------
>> +	 * [S]   osq_unlock()
>> +	 *	 MB
>> +	 * [RmW] rwsem_try_write_lock()
>> +	 */
> Ordering comes in pairs, this is incomplete.

I am sorry that I am a bit sloppy here. I have just sent out an updated 
patch to remedy this. I have added a smp_mb__after_atomic() to ensure 
proper memory ordering. However, I am not so sure if this primitive or 
just a simple smp_rmb() will be more expensive in other non-x86 
architectures.

Cheers,
Longman

  reply	other threads:[~2015-04-23 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-18  2:03 [PATCH] locking/rwsem: reduce spinlock contention in wakeup after up_read/up_write Waiman Long
2015-04-18 15:40 ` Peter Zijlstra
2015-04-23 18:41   ` Waiman Long [this message]
2015-04-20 20:23 ` Jason Low
2015-04-22 20:19   ` Waiman Long

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=55393CD9.2060703@hp.com \
    --to=waiman.long@hp.com \
    --cc=doug.hatch@hp.com \
    --cc=jason.low2@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.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