Re: 2.6.25-rc9 -- INFO: possible circular locking dependencydetected

From: Heiko Carstens
Date: Mon Apr 14 2008 - 11:20:02 EST


On Mon, Apr 14, 2008 at 08:18:01PM +0530, Gautham R Shenoy wrote:
> On Mon, Apr 14, 2008 at 02:42:27PM +0200, Peter Zijlstra wrote:

While you're fixing the cpu hotplug stuff anyway, there's still a bug
present in a few modules init code:

Usually they do something like:

register_hotcpu_notifier(...);
for_each_online_cpu(i)
...

A module's init functions gets called from sys_init_module and there is nothing
that would protect from cpu hotplug.
Therefore the sequence of for_each_online_cpu() and register_hotcpu_notifier()
better should be protected by a surrounding get/put_online_cpus() like this:

get_online_cpus();
register_hotcpu_notifier(...);
for_each_online_cpu(i)
...
put_online_cpus();

But as far as I can see that can lead to a deadlock if e.g. cpu 0 would
execute the code above whild cpu 1 is executing some cpu hotplug code:

cpu0: get_online_cpus()
-> increase cpu_hotplug.refcount
cpu1: cpu_down()
-> cpu_maps_update_begin()
-> grab cpu_add_remove_lock
-> wait for cpu_hotplug.refcount to drop to zero again
cpu0: register_hotcpu_notifier()
-> cpu_maps_update_begin
-> tries to grab cpu_add_remove_lock that cpu 1 holds already
-> dead
--
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/