From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: [PATCH 17/20] mutex: Provide mutex_is_contended Date: Sat, 28 Aug 2010 16:16:54 +0200 Message-ID: <20100828142456.590755447@chello.nl> References: <20100828141637.421594670@chello.nl> Return-path: Content-Disposition: inline; filename=mutex-is-contended.patch Sender: linux-kernel-owner@vger.kernel.org To: Andrea Arcangeli , Avi Kivity , Thomas Gleixner , Rik van Riel , Ingo Molnar , akpm@linux-fou Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Benjamin Herrenschmidt , David Miller , Hugh Dickins , Mel Gorman , Nick Piggin , Peter Zijlstra , Paul McKenney , Yanmin Zhang , Stephen Rothwell List-Id: linux-arch.vger.kernel.org Usable for lock-breaks and such. Signed-off-by: Peter Zijlstra --- include/linux/mutex.h | 5 +++++ 1 file changed, 5 insertions(+) Index: linux-2.6/include/linux/mutex.h =================================================================== --- linux-2.6.orig/include/linux/mutex.h +++ linux-2.6/include/linux/mutex.h @@ -118,6 +118,11 @@ static inline int mutex_is_locked(struct return atomic_read(&lock->count) != 1; } +static inline int mutex_is_contended(struct mutex *lock) +{ + return atomic_read(&lock->count) < 0; +} + /* * See kernel/mutex.c for detailed documentation of these APIs. * Also see Documentation/mutex-design.txt. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from casper.infradead.org ([85.118.1.10]:42781 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753528Ab0H1O1t (ORCPT ); Sat, 28 Aug 2010 10:27:49 -0400 Message-ID: <20100828142456.590755447@chello.nl> Date: Sat, 28 Aug 2010 16:16:54 +0200 From: Peter Zijlstra Subject: [PATCH 17/20] mutex: Provide mutex_is_contended References: <20100828141637.421594670@chello.nl> Content-Disposition: inline; filename=mutex-is-contended.patch Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andrea Arcangeli , Avi Kivity , Thomas Gleixner , Rik van Riel , Ingo Molnar , akpm@linux-foundation.org, Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Benjamin Herrenschmidt , David Miller , Hugh Dickins , Mel Gorman , Nick Piggin , Peter Zijlstra , Paul McKenney , Yanmin Zhang , Stephen Rothwell Message-ID: <20100828141654.kJ57UWLjIXe0-v8HOFN4z6mva4v8D6T4YfhEXeClhzA@z> Usable for lock-breaks and such. Signed-off-by: Peter Zijlstra --- include/linux/mutex.h | 5 +++++ 1 file changed, 5 insertions(+) Index: linux-2.6/include/linux/mutex.h =================================================================== --- linux-2.6.orig/include/linux/mutex.h +++ linux-2.6/include/linux/mutex.h @@ -118,6 +118,11 @@ static inline int mutex_is_locked(struct return atomic_read(&lock->count) != 1; } +static inline int mutex_is_contended(struct mutex *lock) +{ + return atomic_read(&lock->count) < 0; +} + /* * See kernel/mutex.c for detailed documentation of these APIs. * Also see Documentation/mutex-design.txt.