From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756887Ab0DBO1R (ORCPT ); Fri, 2 Apr 2010 10:27:17 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:49471 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754719Ab0DBO1J (ORCPT ); Fri, 2 Apr 2010 10:27:09 -0400 Message-Id: <20100402142446.471408841@chello.nl> User-Agent: quilt/0.47-1 Date: Fri, 02 Apr 2010 16:16:06 +0200 From: Peter Zijlstra To: Andrea Arcangeli , Avi Kivity , Thomas Gleixner , Rik van Riel , Ingo Molnar , akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Hugh Dickins , Mel Gorman , Nick Piggin , Peter Zijlstra Subject: [PATCH 5/7] mutex: Provide mutex_is_contended References: <20100402141601.435955404@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.