From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753196Ab1AYR7Y (ORCPT ); Tue, 25 Jan 2011 12:59:24 -0500 Received: from casper.infradead.org ([85.118.1.10]:59862 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222Ab1AYR7U (ORCPT ); Tue, 25 Jan 2011 12:59:20 -0500 Message-Id: <20110125174907.890366530@chello.nl> User-Agent: quilt/0.48-1 Date: Tue, 25 Jan 2011 18:31:24 +0100 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, linux-mm@kvack.org, Benjamin Herrenschmidt , David Miller , Hugh Dickins , Mel Gorman , Nick Piggin , Peter Zijlstra , Paul McKenney , Yanmin Zhang Subject: [PATCH 13/25] mutex: Provide mutex_is_contended References: <20110125173111.720927511@chello.nl> Content-Disposition: inline; filename=peter_zijlstra-mutex-provide_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. Reviewed-by: KAMEZAWA Hiroyuki 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 @@ -126,6 +126,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.