From: Waiman Long <waiman.long@hp.com>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Rik van Riel <riel@redhat.com>,
Davidlohr Bueso <davidlohr.bueso@hp.com>,
Alex Shi <alex.shi@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrea Arcangeli <aarcange@redhat.com>,
Matthew R Wilcox <matthew.r.wilcox@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Michel Lespinasse <walken@google.com>,
Andi Kleen <andi@firstfloor.org>,
"Chandramouleeswaran, Aswin" <aswin@hp.com>,
"Norton, Scott J" <scott.norton@hp.com>
Subject: Re: [PATCH] rwsem: reduce spinlock contention in wakeup code path
Date: Fri, 27 Sep 2013 20:46:41 -0400 [thread overview]
Message-ID: <524626F1.6010104@hp.com> (raw)
In-Reply-To: <5245DD4E.60009@hurleysoftware.com>
On 09/27/2013 03:32 PM, Peter Hurley wrote:
> On 09/27/2013 03:00 PM, Waiman Long wrote:
>> With the 3.12-rc2 kernel, there is sizable spinlock contention on
>> the rwsem wakeup code path when running AIM7's high_systime workload
>> on a 8-socket 80-core DL980 (HT off) as reported by perf:
>>
>> 7.64% reaim [kernel.kallsyms] [k] _raw_spin_lock_irqsave
>> |--41.77%-- rwsem_wake
>> 1.61% reaim [kernel.kallsyms] [k] _raw_spin_lock_irq
>> |--92.37%-- rwsem_down_write_failed
>>
>> That was 4.7% of recorded CPU cycles.
>>
>> On a large NUMA machine, it is entirely possible that a fairly large
>> number of threads are queuing up in the ticket spinlock queue to do
>> the wakeup operation. In fact, only one will be needed. This patch
>> tries to reduce spinlock contention by doing just that.
>>
>> A new wakeup field is added to the rwsem structure. This field is
>> set on entry to rwsem_wake() and __rwsem_do_wake() to mark that a
>> thread is pending to do the wakeup call. It is cleared on exit from
>> those functions.
>>
>> By checking if the wakeup flag is set, a thread can exit rwsem_wake()
>> immediately if another thread is pending to do the wakeup instead of
>> waiting to get the spinlock and find out that nothing need to be done.
>
> This will leave readers stranded if a former writer is in __rwsem_do_wake
> to wake up the readers and another writer steals the lock, but before
> the former writer exits without having woken up the readers, the locking
> stealing writer drops the lock and sees the wakeup flag is set, so
> doesn't bother to wake the readers.
>
> Regards,
> Peter Hurley
>
Yes, you are right. That can be a problem. Thank for pointing this out.
The workloads that I used doesn't seem to exercise the readers. I will
modify the patch to add code handle this failure case by resetting the
wakeup flag, pushing it out and then retrying one more time to get the
read lock. I think that should address the problem.
Regards,
Longman
prev parent reply other threads:[~2013-09-28 0:47 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-27 19:00 Waiman Long
2013-09-27 19:28 ` Linus Torvalds
2013-09-27 19:39 ` Davidlohr Bueso
2013-09-27 21:49 ` Tim Chen
2013-09-28 6:45 ` Ingo Molnar
2013-09-28 7:41 ` Ingo Molnar
2013-09-28 18:55 ` Linus Torvalds
2013-09-28 19:13 ` Andi Kleen
2013-09-28 19:22 ` Linus Torvalds
2013-09-28 19:21 ` Ingo Molnar
2013-09-28 19:33 ` Linus Torvalds
2013-09-28 19:39 ` Ingo Molnar
2013-09-30 10:44 ` Peter Zijlstra
2013-09-30 16:13 ` Linus Torvalds
2013-09-30 16:41 ` Peter Zijlstra
2013-10-01 7:28 ` Ingo Molnar
2013-10-01 8:09 ` Peter Zijlstra
2013-10-01 8:25 ` Ingo Molnar
2013-09-30 15:58 ` Waiman Long
2013-10-01 7:33 ` Ingo Molnar
2013-10-01 20:03 ` Waiman Long
2013-09-28 19:37 ` [PATCH] anon_vmas: Convert the rwsem to an rwlock_t Ingo Molnar
2013-09-28 19:43 ` Linus Torvalds
2013-09-28 19:46 ` Ingo Molnar
2013-09-28 19:52 ` [PATCH, v2] " Ingo Molnar
2013-09-30 11:00 ` Peter Zijlstra
2013-09-30 11:44 ` Peter Zijlstra
2013-09-30 17:03 ` Andrew Morton
2013-09-30 17:25 ` Linus Torvalds
2013-09-30 17:10 ` Tim Chen
2013-09-30 18:14 ` Peter Zijlstra
2013-09-30 19:23 ` Tim Chen
2013-09-30 19:35 ` Waiman Long
2013-09-30 19:47 ` Tim Chen
2013-09-30 22:03 ` Tim Chen
2013-10-01 2:41 ` Waiman Long
2013-09-30 8:52 ` [PATCH] " Andrea Arcangeli
2013-09-30 14:40 ` Jerome Glisse
2013-09-30 16:26 ` Linus Torvalds
2013-09-30 19:16 ` Andrea Arcangeli
2013-09-30 18:21 ` Andi Kleen
2013-09-30 19:04 ` Jerome Glisse
2013-09-29 23:06 ` [PATCH] rwsem: reduce spinlock contention in wakeup code path Davidlohr Bueso
2013-09-29 23:26 ` Linus Torvalds
2013-09-30 0:40 ` Davidlohr Bueso
2013-09-30 0:51 ` Linus Torvalds
2013-09-30 6:57 ` Ingo Molnar
2013-09-30 1:11 ` Michel Lespinasse
2013-09-30 7:05 ` Ingo Molnar
2013-09-30 16:03 ` Waiman Long
2013-09-30 10:46 ` Peter Zijlstra
2013-10-01 7:48 ` Ingo Molnar
2013-10-01 8:10 ` Peter Zijlstra
2013-09-27 19:32 ` Peter Hurley
2013-09-28 0:46 ` Waiman Long [this message]
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=524626F1.6010104@hp.com \
--to=waiman.long@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@intel.com \
--cc=andi@firstfloor.org \
--cc=aswin@hp.com \
--cc=dave.hansen@intel.com \
--cc=davidlohr.bueso@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.r.wilcox@intel.com \
--cc=mingo@elte.hu \
--cc=peter@hurleysoftware.com \
--cc=riel@redhat.com \
--cc=scott.norton@hp.com \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=walken@google.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
Powered by JetHome