Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754792AbZAMQRk (ORCPT ); Tue, 13 Jan 2009 11:17:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752212AbZAMQR1 (ORCPT ); Tue, 13 Jan 2009 11:17:27 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:38295 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbZAMQRZ (ORCPT ); Tue, 13 Jan 2009 11:17:25 -0500 Date: Tue, 13 Jan 2009 08:16:19 -0800 (PST) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: Peter Zijlstra cc: Ingo Molnar , "Paul E. McKenney" , Gregory Haskins , Matthew Wilcox , Andi Kleen , Chris Mason , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel , linux-btrfs , Thomas Gleixner , Nick Piggin , Peter Morreale , Sven Dietrich , Dmitry Adamushko Subject: Re: [PATCH -v9][RFC] mutex: implement adaptive spinning In-Reply-To: <1231859742.442.128.camel@twins> Message-ID: References: <1231774622.4371.96.camel@laptop> <1231859742.442.128.camel@twins> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1021 Lines: 32 On Tue, 13 Jan 2009, Peter Zijlstra wrote: > > Change mutex contention behaviour such that it will sometimes busy wait on > acquisition - moving its behaviour closer to that of spinlocks. Okey, dokey. Looks reasonable, but I wonder if this part came from v8 and wasn't intentional: > + if (atomic_xchg(&lock->count, -1) == 1) { > + lock_acquired(&lock->dep_map, ip); > + mutex_set_owner(lock); > + preempt_enable(); > + return 0; > + } Now you're forcing the slow-path on unlock. Maybe it was intentional, maybe it wasn't. Did you perhaps mean if (atomic_cmpxchg(&lock->count, 1, 0) == 1) { here? I thought we agreed it was safe, if only because it should be equivalent to just having done "mutex_trylock()" instead of a "real" lock sequence. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/