From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH -v9][RFC] mutex: implement adaptive spinning Date: Tue, 13 Jan 2009 08:16:19 -0800 (PST) Message-ID: References: <1231774622.4371.96.camel@laptop> <1231859742.442.128.camel@twins> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 To: Peter Zijlstra Return-path: In-Reply-To: <1231859742.442.128.camel@twins> List-ID: 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