From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ea0-f170.google.com ([209.85.215.170]:42191 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344Ab3HCKdH (ORCPT ); Sat, 3 Aug 2013 06:33:07 -0400 Received: by mail-ea0-f170.google.com with SMTP id h14so732861eak.15 for ; Sat, 03 Aug 2013 03:33:05 -0700 (PDT) Received: from al.localnet (al.lekensteyn.nl. [2001:470:1f15:b83::c0d1:f1ed]) by mx.google.com with ESMTPSA id j2sm18474589eep.6.2013.08.03.03.33.03 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 03 Aug 2013 03:33:04 -0700 (PDT) From: Peter Wu To: linux-pci@vger.kernel.org Subject: Lockdep warning on rescan (pci_remove_rescan_mutex) Date: Sat, 03 Aug 2013 12:33:02 +0200 Message-ID: <2381207.2TMynsda9i@al> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: linux-pci-owner@vger.kernel.org List-ID: Hi, When trying to rescan for PCI devices (after removing a child), I get a lockdep warning in my logs. The commands were: # tee /sys/bus/pci/devices/0000\:03\:00.0/remove <<<1 1 # tee /sys/bus/pci/devices/0000\:02\:00.0/rescan <<<1 1 I did not experience actual issues, just letting you know about this. I can reproduce this on every reboot: 1. Boot 2. (pci-stub owns the device) 4. remove from parent bus 5. rescan 6. Lockdep warning found. (7. pci-stub claims device again) Interestingly, I can only reproduce this after freshly rebooting. Repeating steps 4 and 5 do not trigger a new lockdep warning. Regards, Peter ====================================================== [ INFO: possible circular locking dependency detected ] 3.11.0-rc2-cold-00096-gae2ad35-dirty #1 Tainted: G O ------------------------------------------------------- tee/29902 is trying to acquire lock: (pci_remove_rescan_mutex){+.+.+.}, at: [] dev_rescan_store+0x56/0x80 but task is already holding lock: (s_active#296){++++.+}, at: [] sysfs_write_file+0xcd/0x170 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (s_active#296){++++.+}: [] check_prevs_add+0xda/0x140 [] validate_chain.isra.35+0x5aa/0x7a0 [] __lock_acquire+0x3ca/0xab0 [] lock_acquire+0x90/0x140 [] sysfs_deactivate+0x116/0x160 [] sysfs_addrm_finish+0x3b/0x70 [] sysfs_hash_and_remove+0x5b/0xb0 [] remove_files.isra.1+0x41/0x80 [] sysfs_remove_group+0x54/0xf0 [] device_remove_groups+0x3b/0x60 [] device_remove_attrs+0x53/0x90 [] device_del+0x12b/0x1c0 [] pci_stop_bus_device+0x9c/0xb0 [] pci_stop_and_remove_bus_device+0x16/0x30 [] remove_callback+0x2b/0x40 [] sysfs_schedule_callback_work+0x18/0x80 [] process_one_work+0x1d1/0x570 [] worker_thread+0x11b/0x370 [] kthread+0xea/0xf0 [] ret_from_fork+0x7c/0xb0 -> #0 (pci_remove_rescan_mutex){+.+.+.}: [] check_prev_add+0x778/0x780 [] check_prevs_add+0xda/0x140 [] validate_chain.isra.35+0x5aa/0x7a0 [] __lock_acquire+0x3ca/0xab0 [] lock_acquire+0x90/0x140 [] mutex_lock_nested+0x70/0x380 [] dev_rescan_store+0x56/0x80 [] dev_attr_store+0x18/0x30 [] sysfs_write_file+0xe6/0x170 [] vfs_write+0xce/0x200 [] SyS_write+0x55/0xa0 [] system_call_fastpath+0x16/0x1b other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(s_active#296); lock(pci_remove_rescan_mutex); lock(s_active#296); lock(pci_remove_rescan_mutex); *** DEADLOCK *** 3 locks held by tee/29902: #0: (sb_writers#6){.+.+.+}, at: [] vfs_write+0x1d3/0x200 #1: (&buffer->mutex){+.+.+.}, at: [] sysfs_write_file+0x44/0x170 #2: (s_active#296){++++.+}, at: [] sysfs_write_file+0xcd/0x170 stack backtrace: CPU: 2 PID: 29902 Comm: tee Tainted: G O 3.11.0-rc2-cold-00096-gae2ad35-dirty #1 Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./Z68X-UD3H-B3, BIOS U1l 03/08/2013 ffff880597c7c6c8 ffff880544e69b28 ffffffff8166cea7 0000000000000000 0000000000000000 ffff880544e69b78 ffffffff81662c09 ffffffff821ac670 ffff880544e69ba0 ffff880544e69b78 ffff880597c7c6a0 ffff880597c7c6c8 Call Trace: [] dump_stack+0x55/0x76 [] print_circular_bug+0xd3/0xe4 [] check_prev_add+0x778/0x780 [] ? get_page_from_freelist+0x23e/0x5f0 [] check_prevs_add+0xda/0x140 [] validate_chain.isra.35+0x5aa/0x7a0 [] __lock_acquire+0x3ca/0xab0 [] ? __alloc_pages_nodemask+0x162/0x980 [] ? dev_rescan_store+0x56/0x80 [] lock_acquire+0x90/0x140 [] ? dev_rescan_store+0x56/0x80 [] mutex_lock_nested+0x70/0x380 [] ? dev_rescan_store+0x56/0x80 [] ? sysfs_write_file+0xcd/0x170 [] ? _kstrtoull+0x2c/0x90 [] dev_rescan_store+0x56/0x80 [] dev_attr_store+0x18/0x30 [] sysfs_write_file+0xe6/0x170 [] vfs_write+0xce/0x200 [] SyS_write+0x55/0xa0 [] system_call_fastpath+0x16/0x1b pci_bus 0000:02: scanning bus pci 0000:02:00.0: scanning [bus 03-03] behind bridge, pass 0 pci_bus 0000:03: scanning bus pci 0000:03:00.0: [10ec:8129] type 00 class 0x020000 pci 0000:03:00.0: reg 0x10: [io 0xe000-0xe0ff] pci 0000:03:00.0: reg 0x14: [mem 0xf7b41000-0xf7b410ff] pci 0000:03:00.0: reg 0x30: [mem 0xf7b00000-0xf7b3ffff pref] pci 0000:03:00.0: PME# supported from D3cold pci 0000:03:00.0: PME# disabled pci_bus 0000:03: bus scan returning with max=03 pci 0000:02:00.0: scanning [bus 03-03] behind bridge, pass 1 pci_bus 0000:02: bus scan returning with max=03 pci 0000:02:00.0: BAR 15: assigned [mem 0xdfb00000-0xdfbfffff pref] pci 0000:03:00.0: BAR 6: assigned [mem 0xdfb00000-0xdfb3ffff pref] pci 0000:03:00.0: BAR 0: assigned [io 0xe000-0xe0ff] pci 0000:03:00.0: BAR 0: set to [io 0xe000-0xe0ff] (PCI address [0xe000-0xe0ff]) pci 0000:03:00.0: BAR 1: assigned [mem 0xf7b00000-0xf7b000ff] pci 0000:03:00.0: BAR 1: set to [mem 0xf7b00000-0xf7b000ff] (PCI address [0xf7b00000-0xf7b000ff]) pci-stub 0000:03:00.0: claimed by stub