Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbYCLJZg (ORCPT ); Wed, 12 Mar 2008 05:25:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751272AbYCLJZ1 (ORCPT ); Wed, 12 Mar 2008 05:25:27 -0400 Received: from viefep20-int.chello.at ([62.179.121.40]:36046 "EHLO viefep20-int.chello.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750965AbYCLJZ0 (ORCPT ); Wed, 12 Mar 2008 05:25:26 -0400 Subject: Re: [2.6.25-rc5-mm1] BUG() at mnt_want_write(). From: Peter Zijlstra To: Andrew Morton Cc: Dave Hansen , penguin-kernel@i-love.sakura.ne.jp, linux-kernel@vger.kernel.org, Christoph Hellwig , Greg KH , Kay Sievers , Ingo Molnar , Matthew Wilcox In-Reply-To: <20080311202212.9fe1e5c1.akpm@linux-foundation.org> References: <200803120137.m2C1bffL037440@www262.sakura.ne.jp> <1205291010.9828.60.camel@nimitz.home.sr71.net> <20080311202212.9fe1e5c1.akpm@linux-foundation.org> Content-Type: text/plain Date: Wed, 12 Mar 2008 10:25:18 +0100 Message-Id: <1205313918.8514.215.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.21.92 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3250 Lines: 90 On Tue, 2008-03-11 at 20:22 -0700, Andrew Morton wrote: > On Tue, 11 Mar 2008 20:03:30 -0700 Dave Hansen wrote: > > > On Wed, 2008-03-12 at 10:37 +0900, penguin-kernel@i-love.sakura.ne.jp > > ... > > > checking TSC synchronization [CPU#0 -> CPU#1]: passed. > > > Brought up 2 CPUs > > > khelper used greatest stack depth: 2684 bytes left > > > net_namespace: 320 bytes > > > NET: Registered protocol family 16 > > > INFO: trying to register non-static key. It means the lock_class_key ended up in non-static storage. In practise it often means you initialized a on-stack structure incorrectly. DECLARE_WAIT_QUEUE_HEAD() vs DECLARE_WAIT_QUEUE_HEAD_ONSTACK() for example. > > > the code is fine but needs lockdep annotation. > > > turning off the locking correctness validator. > > > Pid: 1, comm: swapper Not tainted 2.6.25-rc5-mm1 #1 > > > [] __lock_acquire+0x194/0x6a3 > > > [] ? cache_free_debugcheck+0x1fd/0x219 > > > [] ? kfree+0xdb/0xe5 > > > [] lock_acquire+0x6a/0x87 > > > [] ? down+0xc/0x2f > > > [] _spin_lock_irqsave+0x25/0x55 > > > [] ? down+0xc/0x2f > > > [] down+0xc/0x2f > > > [] device_add+0x152/0x243 > > > [] device_register+0x12/0x15 > > > [] device_create+0x76/0x90 > > > [] vtconsole_class_init+0x72/0xb9 > > > [] ? kernel_init+0x0/0x88 > > > [] do_initcalls+0x59/0x134 > > > [] ? register_irq_proc+0xb1/0xca > > > [] ? proc_symlink+0x5/0x73 > > > [] ? kernel_init+0x0/0x88 > > > [] do_basic_setup+0x1c/0x1e > > > [] kernel_init+0x4d/0x88 > > > [] kernel_thread_helper+0x7/0x10 > > > ======================= > > /me & git fetch mm && git checkout mm/v2.6.25-rc5-mm1 /me twiddles thumbs.. /me tries to untangle the sysfs stuff, finds nothing wrong, looks at semaphore code, and.. the winner is: Matthew messed up the semaphores. Tssk, rewriting locking primitives and not using lockdep... Compile tested defconfig with lockdep and !lockdep. --- Subject: lockdep: fixup the new semaphore implementation The new semaphores failed to properly initialize its spinlock. Non static spinlocks should use spin_lock_init(). Alternatively you should supply a static key yourself. Signed-off-by: Peter Zijlstra --- include/linux/semaphore.h | 4 ++++ 1 file changed, 4 insertions(+) Index: linux-2.6/include/linux/semaphore.h =================================================================== --- linux-2.6.orig/include/linux/semaphore.h +++ linux-2.6/include/linux/semaphore.h @@ -41,7 +41,11 @@ struct semaphore { static inline void sema_init(struct semaphore *sem, int val) { + static struct lock_class_key __key; + *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); + + lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); } #define init_MUTEX(sem) sema_init(sem, 1) -- 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/