Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756716AbZAMQla (ORCPT ); Tue, 13 Jan 2009 11:41:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753056AbZAMQlP (ORCPT ); Tue, 13 Jan 2009 11:41:15 -0500 Received: from bombadil.infradead.org ([18.85.46.34]:49460 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752709AbZAMQlN (ORCPT ); Tue, 13 Jan 2009 11:41:13 -0500 Subject: Re: [PATCH -v9][RFC] mutex: implement adaptive spinning From: Peter Zijlstra To: Linus Torvalds 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 In-Reply-To: <1231863710.7141.3.camel@twins> References: <1231774622.4371.96.camel@laptop> <1231859742.442.128.camel@twins> <1231863710.7141.3.camel@twins> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Tue, 13 Jan 2009 17:40:54 +0100 Message-Id: <1231864854.7141.8.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1742 Lines: 44 On Tue, 2009-01-13 at 17:21 +0100, Peter Zijlstra wrote: > On Tue, 2009-01-13 at 08:16 -0800, Linus Torvalds wrote: > > > > 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. > > Yes, that was an 'accident' from -v8, yes we did think the cmpxchg was > good, however I did get some spurious lockups on -v7, and I only noticed > the thing after I'd done most of the testing, so I decided to let it be > for now. > > Let me put the cmpxchg back in and see if this is all still good (only > 3*2*2 configs to test :-). Ok, tested only 1, but that was the one I remember lockups from -- and that seems to be good with the cmpxchg. Do you fancy me sending v10 or will you make that change locally? -- 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/