From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: [PATCH 17/20] mutex: Provide mutex_is_contended Date: Mon, 18 Oct 2010 13:24:50 +0200 Message-ID: <20101018112951.178962037@chello.nl> References: <20101018112433.556591568@chello.nl> Return-path: Received: from canuck.infradead.org ([134.117.69.58]:60282 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755348Ab0JRLfr (ORCPT ); Mon, 18 Oct 2010 07:35:47 -0400 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-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 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 canuck.infradead.org ([134.117.69.58]:60282 "EHLO canuck.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755348Ab0JRLfr (ORCPT ); Mon, 18 Oct 2010 07:35:47 -0400 Message-ID: <20101018112951.178962037@chello.nl> Date: Mon, 18 Oct 2010 13:24:50 +0200 From: Peter Zijlstra Subject: [PATCH 17/20] mutex: Provide mutex_is_contended References: <20101018112433.556591568@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: <20101018112450.V2JTSUW1ObEis1WU9dXdF8k3MTwWjaisrVVhSac0KRo@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.