From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933421Ab0DHTam (ORCPT ); Thu, 8 Apr 2010 15:30:42 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:47323 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933404Ab0DHTae (ORCPT ); Thu, 8 Apr 2010 15:30:34 -0400 Message-Id: <20100408192723.072839778@chello.nl> User-Agent: quilt/0.47-1 Date: Thu, 08 Apr 2010 21:17:48 +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 Subject: [PATCH 11/13] mutex: Provide mutex_is_contended References: <20100408191737.296180458@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.