From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932596AbdCGQFN (ORCPT ); Tue, 7 Mar 2017 11:05:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56956 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755737AbdCGQES (ORCPT ); Tue, 7 Mar 2017 11:04:18 -0500 From: Waiman Long To: Ingo Molnar , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Waiman Long Subject: [PATCH] locking/rwsem: Make rwsem_is_contended() track status of OSQ Date: Tue, 7 Mar 2017 11:03:48 -0500 Message-Id: <1488902628-14948-1-git-send-email-longman@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 07 Mar 2017 16:04:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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