Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759762AbZAHRdx (ORCPT ); Thu, 8 Jan 2009 12:33:53 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754314AbZAHRdk (ORCPT ); Thu, 8 Jan 2009 12:33:40 -0500 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:63310 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754281AbZAHRdi (ORCPT ); Thu, 8 Jan 2009 12:33:38 -0500 Date: Thu, 8 Jan 2009 12:33:35 -0500 (EST) From: Steven Rostedt X-X-Sender: rostedt@gandalf.stny.rr.com To: Chris Mason cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , paulmck@linux.vnet.ibm.com, Gregory Haskins , Matthew Wilcox , Andi Kleen , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel , linux-btrfs , Thomas Gleixner , Nick Piggin , Peter Morreale , Sven Dietrich Subject: Re: [PATCH -v7][RFC]: mutex: implement adaptive spinning In-Reply-To: <1231434515.14304.27.camel@think.oraclecorp.com> Message-ID: References: <1231347442.11687.344.camel@twins> <1231365115.11687.361.camel@twins> <1231366716.11687.377.camel@twins> <1231408718.11687.400.camel@twins> <20090108141808.GC11629@elte.hu> <1231426014.11687.456.camel@twins> <1231434515.14304.27.camel@think.oraclecorp.com> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) 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: 3070 Lines: 105 On Thu, 8 Jan 2009, Chris Mason wrote: > On Thu, 2009-01-08 at 08:58 -0800, Linus Torvalds wrote: > > > > Ok, I've gone through -v7, and I'm sure you're all shocked to hear it, but > > I have no complaints. Except that you dropped all the good commit > > commentary you had earlier ;) > > > > Seems to get stuck under load. I've hit it with make -j 50 on ext3 and > with my btrfs benchmarking. This was against the latest git from about > 5 minutes ago. > > -chris > > BUG: soft lockup - CPU#3 stuck for 61s! [python:3970] CPU 3: Modules > linked in: netconsole configfs btrfs zlib_deflate loop e1000e 3w_9xxx > Pid: 3970, comm: python Not tainted 2.6.28 #1 Call Trace: > [] ? __cmpxchg+0x9/0x3f > [] ? __mutex_lock_common+0x3d/0x178 Hmm, looking at the code... mutex.c: for (;;) { struct thread_info *owner; old_val = atomic_cmpxchg(&lock->count, 1, 0); if (old_val == 1) { lock_acquired(&lock->dep_map, ip); mutex_set_owner(lock); return 0; } if (old_val < 0 && !list_empty(&lock->wait_list)) break; /* See who owns it, and spin on him if anybody */ owner = ACCESS_ONCE(lock->owner); if (owner && !spin_on_owner(lock, owner)) break; cpu_relax(); } and in sched.c: int spin_on_owner(struct mutex *lock, struct thread_info *owner) { unsigned int cpu; struct rq *rq; int ret = 1; [...] if (lock->owner != owner) break; We keep spinning if the owner changes. I wonder if you have many CPUS (Chris, how many cpus did this box have?), you could get one task constantly spinning while the mutex keeps changing owners on the other CPUS. Perhaps, we should do something like: mutex.c: for (;;) { struct thread_info *owner = NULL; old_val = atomic_cmpxchg(&lock->count, 1, 0); if (old_val == 1) { lock_acquired(&lock->dep_map, ip); mutex_set_owner(lock); return 0; } if (old_val < 0 && !list_empty(&lock->wait_list)) break; /* See who owns it, and spin on him if anybody */ if (!owner) owner = ACCESS_ONCE(lock->owner); if (owner && !spin_on_owner(lock, owner)) break; cpu_relax(); } Or just pull assigning of the owner out of the loop. This way, we go to sleep if the owner changes and is not NULL. Just a thought, -- Steve -- 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/