From: Waiman Long <longman@redhat.com>
To: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Waiman Long <longman@redhat.com>
Subject: [PATCH] locking/rwsem: Make rwsem_is_contended() track status of OSQ
Date: Tue, 7 Mar 2017 11:03:48 -0500 [thread overview]
Message-ID: <1488902628-14948-1-git-send-email-longman@redhat.com> (raw)
It was found that the current rwsem_is_contended() function did not
look at the status of the OSQ and hence would miss waiters on OSQ. So
that function is now modified to look at the OSQ as well.
Signed-off-by: Waiman Long <longman@redhat.com>
---
include/linux/rwsem.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index dd1d142..9cb64e3 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -71,8 +71,18 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
+
+static inline bool rwsem_osq_is_locked(struct rw_semaphore *sem)
+{
+ return osq_is_locked(&sem->osq);
+}
#else
#define __RWSEM_OPT_INIT(lockname)
+
+static inline bool rwsem_osq_is_locked(struct rw_semaphore *sem)
+{
+ return false;
+}
#endif
#define __RWSEM_INITIALIZER(name) \
@@ -103,7 +113,7 @@ extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
*/
static inline int rwsem_is_contended(struct rw_semaphore *sem)
{
- return !list_empty(&sem->wait_list);
+ return !list_empty(&sem->wait_list) || rwsem_osq_is_locked(sem);
}
/*
--
1.8.3.1
next reply other threads:[~2017-03-07 16:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 16:03 Waiman Long [this message]
2017-03-07 17:45 ` Peter Zijlstra
2017-03-07 18:21 ` 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=1488902628-14948-1-git-send-email-longman@redhat.com \
--to=longman@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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®