From: Davidlohr Bueso <dave@stgolabs.net>
To: Waiman Long <longman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org, Joe Mario <jmario@redhat.com>
Subject: Re: [PATCH v3] locking/rwsem: Exit read lock slowpath if queue empty & no writer
Date: Thu, 26 Jul 2018 17:02:15 -0700 [thread overview]
Message-ID: <20180727000215.ez3el2tbbasxa5fk@linux-r8p5> (raw)
In-Reply-To: <1532459425-19204-1-git-send-email-longman@redhat.com>
On Tue, 24 Jul 2018, Waiman Long wrote:
>It was discovered that a constant stream of readers with occassional
>writers pounding on a rwsem may cause many of the readers to enter the
>slowpath unnecessarily thus increasing latency and lowering performance.
>
>In the current code, a reader entering the slowpath critical section
>will unconditionally set the WAITING_BIAS, if not set yet, and clear
>its active count even if no one is in the wait queue and no writer
>is present. This causes some incoming readers to observe the presence
>of waiters in the wait queue and hence have to go into the slowpath
>themselves.
>
>With sufficient numbers of readers and a relatively short lock hold time,
>the WAITING_BIAS may be repeatedly turned on and off and a substantial
>portion of the readers will go into the slowpath sustaining a rather
>long queue in the wait queue spinlock and repeated WAITING_BIAS on/off
>cycle until the logjam is broken opportunistically.
>
>To avoid this situation from happening, an additional check is added to
>detect the special case that the reader in the critical section is the
>only one in the wait queue and no writer is present. When that happens,
>it can just exit the slowpath and return immediately as its active count
>has already been set in the lock. Other incoming readers won't observe
>the presence of waiters and so will not be forced into the slowpath.
>
>The issue was found in a customer site where they had an application
>that pounded on the pread64 syscalls heavily on an XFS filesystem. The
>application was run in a recent 4-socket boxes with a lot of CPUs. They
>saw significant spinlock contention in the rwsem_down_read_failed() call.
>With this patch applied, the system CPU usage went down from 85% to 57%,
>and the spinlock contention in the pread64 syscalls was gone.
>
>v3: Revise the commit log and comment again.
>v2: Add customer testing results and remove wording that may cause
> confusion.
>
>Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Davidlohr Bueso <dbueso@suse.de>
next prev parent reply other threads:[~2018-07-27 0:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 19:10 Waiman Long
2018-07-27 0:02 ` Davidlohr Bueso [this message]
2018-07-27 13:33 ` Will Deacon
2018-08-07 23:29 ` Waiman Long
2018-08-08 10:24 ` Will Deacon
2018-09-10 10:10 ` [tip:locking/core] " tip-bot for 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=20180727000215.ez3el2tbbasxa5fk@linux-r8p5 \
--to=dave@stgolabs.net \
--cc=jmario@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=will.deacon@arm.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®