Re: [RFC PATCH] Suppress a device hot remove related lockdep warning

From: Tejun Heo
Date: Thu Apr 10 2014 - 09:31:33 EST


Hello,

On Thu, Apr 10, 2014 at 05:18:34PM +0800, Li Zhong wrote:
> I noticed following lockdep warning when trying acpi hot-remove cpus:
>
> [84154.204080] ======================================================
> [84154.204080] [ INFO: possible circular locking dependency detected ]
> [84154.204080] 3.14.0-next-20140408+ #24 Tainted: G W
> [84154.204080] -------------------------------------------------------
> [84154.204080] bash/777 is trying to acquire lock:
> [84154.204080] (cpu_add_remove_lock){+.+.+.}, at: [<ffffffff810664a7>] cpu_maps_update_begin+0x17/0x20
> [84154.213203]
> [84154.213203] but task is already holding lock:
> [84154.213203] (s_active#79){++++.+}, at: [<ffffffff81256e14>] kernfs_fop_write+0xe4/0x190
> [84154.213203]
> [84154.213203] which lock already depends on the new lock.
> [84154.213203]
> [84154.213203]
> [84154.213203] the existing dependency chain (in reverse order) is:
> [84154.213203]
...
> [84154.213203] Possible unsafe locking scenario:
> [84154.213203]
> [84154.213203] CPU0 CPU1
> [84154.213203] ---- ----
> [84154.213203] lock(s_active#79);
> [84154.213203] lock(cpu_hotplug.lock#2);
> [84154.213203] lock(s_active#79);
> [84154.213203] lock(cpu_add_remove_lock);
> [84154.213203]
> [84154.213203] *** DEADLOCK ***
> .............
>
> The deadlock itself seems already fixed in commit 5e33bc41.
>
> This patch uses DEVICE_ATTR_IGNORE_LOCKDEP for "online" attr to suppress
> this lockdep warning. But I'm a little afraid it might also hide
> (future) potential real dead lock scenarios?

I suppose this is happening because offlining a cpu involves removing
some sysfs files? If the file isn't trying to remove itself, it
should be okay but I think it could be better to use
kernfs_break_active_protection() from online callback so that the
operation is actually outside the dependency chain rather than just
suppressing lockdep.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/