From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <Waiman.Long@hp.com>
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: Sat, 18 Apr 2015 17:40:14 +0200 [thread overview]
Message-ID: <20150418154014.GV27490@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <1429322598-44362-1-git-send-email-Waiman.Long@hp.com>
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.
> + if (!rwsem_has_spinner(sem))
> + raw_spin_lock_irqsave(&sem->wait_lock, flags);
> + else if (!raw_spin_trylock_irqsave(&sem->wait_lock, flags))
> + return sem;
>
> /* do nothing if list empty */
> if (!list_empty(&sem->wait_list))
> --
> 1.7.1
>
next prev parent reply other threads:[~2015-04-18 19:35 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 [this message]
2015-04-23 18:41 ` Waiman Long
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=20150418154014.GV27490@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=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=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