Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760834Ab2FHPIt (ORCPT ); Fri, 8 Jun 2012 11:08:49 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56059 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757487Ab2FHPIr (ORCPT ); Fri, 8 Jun 2012 11:08:47 -0400 Subject: Re: processes hung after sys_renameat, and 'missing' processes From: Peter Zijlstra To: "J. Bruce Fields" Cc: Linus Torvalds , Dave Jones , Al Viro , Linux Kernel , Miklos Szeredi , Jan Kara In-Reply-To: <20120608144602.GA17251@fieldses.org> References: <20120603231709.GP30000@ZenIV.linux.org.uk> <20120603232820.GQ30000@ZenIV.linux.org.uk> <20120606194233.GA1537@redhat.com> <20120606230040.GA18089@redhat.com> <1339064814.23343.14.camel@twins> <1339140698.23343.26.camel@twins> <20120608144602.GA17251@fieldses.org> Content-Type: text/plain; charset="UTF-8" Date: Fri, 08 Jun 2012 17:08:34 +0200 Message-ID: <1339168114.2507.44.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1352 Lines: 52 On Fri, 2012-06-08 at 10:46 -0400, J. Bruce Fields wrote: > > > > Sadly, if you get that annotation wrong you can annotate an actual > > > > deadlock away. > > What's a (contrived as you want) example where that happens? spinlock_t lock_array[10]; void init_array(void) { int i; for (i = 0; i < ARRAY_SIZE(lock_array); i++) spin_lock_init(array + i); } void double_lock(int a, int b) { spin_lock(lock_array + a); spin_lock_nested(lock_array + b, SINGLE_DEPTH_NESTING); } The above places all locks in the array in the same class, it then does a double lock without order, but tells lockdep the nesting is ok. A correct version of the double_lock() function would look like: void double_lock(int a, int b) { if (b < a) swap(a, b); spin_lock(lock_array + a); spin_lock_nested(lock_array + b, SINGLE_DEPTH_NESTING); } This orders the locks in array order. > > > > This the reason you have to be very careful when > > > > annotating stuff. > > Or alternatively--what do I need to check before I call > mutex_lock_nested? That the lock order you tell lockdep is ok, is indeed correct. -- 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/