From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756023Ab1GOUPp (ORCPT ); Fri, 15 Jul 2011 16:15:45 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:44567 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753563Ab1GOUPn (ORCPT ); Fri, 15 Jul 2011 16:15:43 -0400 Date: Fri, 15 Jul 2011 14:15:41 -0600 From: Grant Likely To: Alexander Stein Cc: linux-kernel@vger.kernel.org Subject: Re: gpiolib.c: possible circular locking dependency detected Message-ID: <20110715201541.GL2833@ponder.secretlab.ca> References: <201107111419.55719.alexander.stein@systec-electronic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201107111419.55719.alexander.stein@systec-electronic.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 11, 2011 at 02:19:55PM +0200, Alexander Stein wrote: > Hello, > > I used a shell script using /sys/class/gpio to export,set/unset and unexport > GPIOs. Upon unexporting GPIOs I get the dmesg shown below. I didn't find any > important change in gpiolib.c and fs/sysfs/dir.c between 2.6.39 and git master > which would fix this. > Has somebody an idea about this? Yeah, there are nasty locking problems in the gpio sysfs interface, but nobody has completed the work of debugging it. Someone with some free cycles could help out here. g. > > Regards, > Alexander > > ======================================================= > [ INFO: possible circular locking dependency detected ] > 2.6.39+ #5 > ------------------------------------------------------- > gpio.sh/765 is trying to acquire lock: > (s_active#40){++++.+}, at: [] sysfs_addrm_finish+0x27/0x4a > but task is already holding lock: > (sysfs_lock){+.+.+.}, at: [] gpio_unexport+0x27/0x77 > > which lock already depends on the new lock. > the existing dependency chain (in reverse order) is: > -> #1 (sysfs_lock){+.+.+.}: > [] validate_chain.clone.14+0x425/0x518 > [] __lock_acquire+0x653/0x6bb > [] lock_acquire+0x63/0x7b > [] mutex_lock_nested+0x45/0x291 > [] gpio_direction_store+0x20/0xab > [] dev_attr_store+0x22/0x27 > [] sysfs_write_file+0xb6/0xe9 > [] vfs_write+0x91/0x10d > [] sys_write+0x3e/0x63 > [] sysenter_do_call+0x12/0x32 > > -> #0 (s_active#40){++++.+}: > [] check_prev_add+0xd5/0x4dd > [] validate_chain.clone.14+0x425/0x518 > [] __lock_acquire+0x653/0x6bb > [] lock_acquire+0x63/0x7b > [] sysfs_deactivate+0x85/0xba > [] sysfs_addrm_finish+0x27/0x4a > [] sysfs_remove_dir+0x5f/0x6d > [] kobject_del+0xf/0x5e > [] device_del+0x12e/0x13a > [] device_unregister+0xb/0x15 > [] gpio_unexport+0x68/0x77 > [] gpio_free+0x1c/0xa3 > [] unexport_store+0x44/0x49 > [] class_attr_store+0x25/0x2a > [] sysfs_write_file+0xb6/0xe9 > [] vfs_write+0x91/0x10d > [] sys_write+0x3e/0x63 > [] sysenter_do_call+0x12/0x32 > > other info that might help us debug this: > > 3 locks held by gpio.sh/765: > #0: (&buffer->mutex){+.+.+.}, at: [] sysfs_write_file+0x25/0xe9 > #1: (s_active#52){.+.+.+}, at: [] sysfs_write_file+0x9b/0xe9 > #2: (sysfs_lock){+.+.+.}, at: [] gpio_unexport+0x27/0x77 > > stack backtrace: > Pid: 765, comm: gpio.sh Not tainted 2.6.39+ #5 > Call Trace: > [] ? printk+0x19/0x1b > [] print_circular_bug+0x94/0x9d > [] check_prev_add+0xd5/0x4dd > [] validate_chain.clone.14+0x425/0x518 > [] ? mark_lock+0x208/0x2d7 > [] __lock_acquire+0x653/0x6bb > [] ? lockdep_init_map+0x8a/0x3c3 > [] ? trace_hardirqs_on+0xb/0xd > [] lock_acquire+0x63/0x7b > [] ? sysfs_addrm_finish+0x27/0x4a > [] sysfs_deactivate+0x85/0xba > [] ? sysfs_addrm_finish+0x27/0x4a > [] sysfs_addrm_finish+0x27/0x4a > [] sysfs_remove_dir+0x5f/0x6d > [] kobject_del+0xf/0x5e > [] device_del+0x12e/0x13a > [] device_unregister+0xb/0x15 > [] gpio_unexport+0x68/0x77 > [] ? gpio_set_value_cansleep+0x1c/0x1c > [] ? gpio_free+0xa3/0xa3 > [] gpio_free+0x1c/0xa3 > [] ? gpio_free+0xa3/0xa3 > [] unexport_store+0x44/0x49 > [] class_attr_store+0x25/0x2a > [] sysfs_write_file+0xb6/0xe9 > [] vfs_write+0x91/0x10d > [] ? sysfs_poll+0x72/0x72 > [] sys_write+0x3e/0x63 > [] sysenter_do_call+0x12/0x32