From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932637Ab0FGLZj (ORCPT ); Mon, 7 Jun 2010 07:25:39 -0400 Received: from [18.85.46.34] ([18.85.46.34]:37699 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755718Ab0FGLUO (ORCPT ); Mon, 7 Jun 2010 07:20:14 -0400 Message-Id: <20100607111408.684909113@chello.nl> User-Agent: quilt/0.48-1 Date: Mon, 07 Jun 2010 13:07:19 +0200 From: Peter Zijlstra 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 E. McKenney" Subject: [PATCH 25/28] mutex: Provide mutex_is_contended References: <20100607110654.606530953@chello.nl> Content-Disposition: inline; filename=mutex-is-contended.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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.