Re: [PATCH 2/2] cpuhotplug: make get_online_cpus() scalability byusing percpu counter

From: Oleg Nesterov
Date: Tue Apr 06 2010 - 08:04:15 EST


On 04/05, Oleg Nesterov wrote:
>
> On 04/05, Lai Jiangshan wrote:
> >
> > 1) get_online_cpus() must be allowed to be called recursively, so I added
> > get_online_cpus_nest for every task for new code.
>
> Well, iirc one of the goals of
>
> cpu-hotplug: replace lock_cpu_hotplug() with get_online_cpus()
> 86ef5c9a8edd78e6bf92879f32329d89b2d55b5a
>
> was avoiding the new members in task_struct. I leave this up to you
> and Gautham.
>
>
> Lai, I didn't read this patch carefully yet (and I can't apply it to
> Linus's tree). But at first glance,

because I tried to apply it without 1/2 ;)

> > void put_online_cpus(void)
> > {
> > ...
> > + if (!--current->get_online_cpus_nest) {
> > + preempt_disable();
> > + __get_cpu_var(refcount)--;
> > + if (cpu_hotplug_task)
> > + wake_up_process(cpu_hotplug_task);
>
> This looks unsafe. In theory nothing protects cpu_hotplug_task from
> exiting if refcount_sum() becomes zero, this means wake_up_process()
> can hit the freed/reused/unmapped task_struct. Probably cpu_hotplug_done()
> needs another synhronize_sched() before return.

Yes, I think this is true, at least in theory.

> OTOH, I do not understand why the result of __get_cpu_var(refcount)
> must be visible to refcount_sum() if we race with cpu_hotplug_begin(),
> so it seems to me cpu_hotplug_begin() also needs synchronize_sched()
> before refcount_sum().

No, I misread the unapplied patch, sorry for noise.

Oleg.

--
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/