From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757399AbYE0KJg (ORCPT ); Tue, 27 May 2008 06:09:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756078AbYE0KJ0 (ORCPT ); Tue, 27 May 2008 06:09:26 -0400 Received: from ug-out-1314.google.com ([66.249.92.169]:62265 "EHLO ug-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756059AbYE0KJY (ORCPT ); Tue, 27 May 2008 06:09:24 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type:content-disposition:user-agent; b=RylKjG0h8A9McDQSnGS+gwTo7dtXFINezU4ykwkobUdTZAjc8fuinBayIWE/vVnrJ5MKkuiIjUs0HdQa3VYHy0in8mXzHeS0MuRvrmpALZGbFa7CPK/oV3Vnbqzwpev63XHc5lQJwIMiRiTVCIyagcRIEQ/9UJJbhSE3y5Mp5XE= Date: Tue, 27 May 2008 18:10:09 +0800 From: Dave Young To: akpm@linux-foundation.org Cc: greg@kroah.com, matthew@wil.cx, kay.sievers@vrfy.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH][-mm] reclassify sg_sysfs_class for lockdep Message-ID: <20080527101009.GA3015@darkstar.te-china.tietoenator.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As register sg_interface, the sg_add will be called, which then will add device to sg_sysfs_class. This will cause lockdep warning, please see following email In this case the locks are from diffrent classi, one is sdev_class, another is sg_sysfs_class Here reclassify the sg_sysfs_class for lockdep Date: Wed, 14 May 2008 08:56:39 -0700 From: Greg KH To: Andrew Morton , Dave Young Cc: linux-scsi@vger.kernel.org, Kay Sievers Subject: Re: lockdep whine in 2.6.26-rc2-mm1 Message-ID: <20080514155639.GB28594@kroah.com> References: <20080514000933.56adc131.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080514000933.56adc131.akpm@linux-foundation.org> User-Agent: Mutt/1.5.16 (2007-06-09) On Wed, May 14, 2008 at 12:09:33AM -0700, Andrew Morton wrote: > > ============================================= > [ INFO: possible recursive locking detected ] > 2.6.26-rc2-mm1 #15 > --------------------------------------------- > modprobe/942 is trying to acquire lock: > (&cls->mutex){--..}, at: [] device_add+0x43d/0x57a > > but task is already holding lock: > (&cls->mutex){--..}, at: [] class_interface_register+0x48/0xbd > > other info that might help us debug this: > 1 lock held by modprobe/942: > #0: (&cls->mutex){--..}, at: [] class_interface_register+0x48/0xbd > > stack backtrace: > Pid: 942, comm: modprobe Not tainted 2.6.26-rc2-mm1 #15 > > Call Trace: > [] __lock_acquire+0x90d/0xc50 > [] ? restore_args+0x0/0x30 > [] ? device_add+0x43d/0x57a > [] lock_acquire+0x91/0xb7 > [] ? device_add+0x43d/0x57a > [] mutex_lock_nested+0xf2/0x278 > [] ? device_add+0x43d/0x57a > [] ? _spin_unlock+0x23/0x28 > [] device_add+0x43d/0x57a > [] device_register+0x16/0x1b > [] device_create+0xdf/0x112 > [] ? trace_hardirqs_on+0xd/0xf > [] ? trace_hardirqs_on+0xd/0xf > [] ? mutex_unlock+0x9/0xb > [] ? kobj_map+0x113/0x124 > [] ? exact_lock+0x0/0x14 > [] ? exact_match+0x0/0x9 > [] :sg:sg_add+0x2a3/0x3bd > [] class_interface_register+0x77/0xbd > [] :scsi_mod:scsi_register_interface+0x11/0x13 > [] :sg:init_sg+0xa3/0x155 > [] sys_init_module+0x1823/0x197a > [] ? seq_release+0x0/0x56 > [] system_call_after_swapgs+0x7b/0x80 Signed-off-by: Dave Young --- drivers/scsi/sg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff -upr linux/drivers/scsi/sg.c linux.new/drivers/scsi/sg.c --- linux/drivers/scsi/sg.c 2008-05-27 17:09:42.000000000 +0800 +++ linux.new/drivers/scsi/sg.c 2008-05-27 17:09:51.000000000 +0800 @@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 #include #include #include +#include #include "scsi.h" #include @@ -67,6 +68,8 @@ static int sg_proc_init(void); static void sg_proc_cleanup(void); #endif +static struct lock_class_key sg_class_key; + #define SG_ALLOW_DIO_DEF 0 #define SG_ALLOW_DIO_CODE /* compile out by commenting this define */ @@ -1579,6 +1582,9 @@ init_sg(void) rc = PTR_ERR(sg_sysfs_class); goto err_out; } + + lockdep_set_class_and_name(&sg_sysfs_class->mutex, &sg_class_key, + sg_sysfs_class->name); sg_sysfs_valid = 1; rc = scsi_register_interface(&sg_interface); if (0 == rc) {