All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Baoquan He <bhe@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, Waiman.Long@hp.com
Subject: Re: [PATCH] locking/rwlocks: clean up of qrwlock
Date: Tue, 16 Dec 2014 10:01:28 +0100	[thread overview]
Message-ID: <20141216090128.GU3337@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1418709640-5625-1-git-send-email-bhe@redhat.com>

On Tue, Dec 16, 2014 at 02:00:40PM +0800, Baoquan He wrote:
> In queue_read_lock_slowpath, when writer count becomes 0, we need
> increment the read count and get the lock. Then need call
> rspin_until_writer_unlock to check again if an incoming writer
> steals the lock in the gap. But in rspin_until_writer_unlock
> it only checks the writer count, namely low 8 bit of lock->cnts,
> no need to subtract the reader count unit specifically. So remove
> that subtraction to make it clearer, rspin_until_writer_unlock
> just takes the actual lock->cnts as the 2nd argument.
> 
> And also change the code comment in queue_write_lock_slowpath to
> make it more exact and explicit.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  kernel/locking/qrwlock.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c
> index f956ede..ae66c10 100644
> --- a/kernel/locking/qrwlock.c
> +++ b/kernel/locking/qrwlock.c
> @@ -76,7 +76,7 @@ void queue_read_lock_slowpath(struct qrwlock *lock)
>  	while (atomic_read(&lock->cnts) & _QW_WMASK)
>  		cpu_relax_lowlatency();
>  
> -	cnts = atomic_add_return(_QR_BIAS, &lock->cnts) - _QR_BIAS;
> +	cnts = atomic_add_return(_QR_BIAS, &lock->cnts);
>  	rspin_until_writer_unlock(lock, cnts);

Did you actually look at the ASM generated? I suspect your change makes
it bigger.

  reply	other threads:[~2014-12-16  9:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-16  6:00 [PATCH] locking/rwlocks: clean up of qrwlock Baoquan He
2014-12-16  9:01 ` Peter Zijlstra [this message]
2014-12-16 15:36   ` Baoquan He
2014-12-17 21:16     ` Waiman Long
2015-01-06  9:25       ` Baoquan He
2015-01-06 10:13         ` Peter Zijlstra
2015-01-06 12:08           ` Baoquan He

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=20141216090128.GU3337@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Waiman.Long@hp.com \
    --cc=bhe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.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 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.