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

From: Heiko Carstens
Date: Tue Apr 15 2008 - 10:37:41 EST


On Tue, Apr 15, 2008 at 07:22:10PM +0530, Gautham R Shenoy wrote:
> On Mon, Apr 14, 2008 at 09:35:39PM +0200, Heiko Carstens wrote:
> > The problem here is that between register_hotcpu_notifier() and
> > get_online_cpus() a cpu might have been hotplugged.
> > So on cpu down the registered function might try to undo something that
> > wasn't prepared in the first place.
> > On cpu up however it will do things twice. Once for the cpus that got
> > added between register_hotcpu_notifier() and for_each_online_cpus()
> > and then again in the for_each_online_cpus() loop.
> >
> > Of course all of these scenarios could be fixed in each driver, but that
> > would be a lot of duplicated work. Making sure the combination of
> > get_online_cpus() and register_hotcpu_notifier() cannot deadlock would
> > make things much easier.
>
> Ah, okay. Thanks for the explanation.
> So how about having a new API,
> something along the lines of:
>
> kernel/cpu.c
> ------------------------------------------------------
> register_hot_cpu_notifier_init(notifier_name, driver_hotcpu_init_function)
> {
> mutex_lock(&cpu_add_remove_lock);
> get_online_cpus();
> __register_hot_cpu_notifier(notifier_name);
> driver_hotcpu_init_function();
> put_online_cpus();
> mutex_unlock(&cpu_add_remove_lock);
> }
>
> drivers/mydriver.c
> --------------------------------------------------------------
> driver_hotcpu_init_function()
> {
> for_each_online_cpus()
> perform_subsystem_hotcpu_initialization();
> }
>
>
> driver_init()
> {
> register_hotcpu_notifier_init(notifier_name,
> driver_hotcpu_init_function);
> }

That looks fine to me.
--
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/