Re: [PATCH] fix-flush_workqueue-vs-cpu_dead-race-update

From: Oleg Nesterov
Date: Sun Jan 07 2007 - 12:09:14 EST


On 01/07, Srivatsa Vaddagiri wrote:
>
> On Sun, Jan 07, 2007 at 03:56:03PM +0300, Oleg Nesterov wrote:
> > Srivatsa, I'm completely new to cpu-hotplug, so please correct me if I'm
> > wrong (in fact I _hope_ I am wrong) but as I see it, the hotplug/workqueue
> > interaction is broken by design, it can't be fixed by changing just locking.
> >
> > Once again. CPU dies, CPU_DEAD calls kthread_stop() and sleeps until
> > cwq->thread exits. To do so, this thread must at least complete the
> > currently running work->func().
>
> If run_workqueue() takes a lock_cpu_hotplug() successfully, then we shouldnt
> even reach till this point, as it will block writers (cpu_down/up) until it
> completes.
>
>
> run_workqueue()
> ---------------
>
> try_again:
> rc = lock_cpu_hotplug_interruptible();
>
> if (rc && kthread_should_stop())
> return;
>
> if (rc != 0)
> goto try_again;
>
> /* cpu_down/up shouldnt happen now untill we call unlock_cpu_hotplug */
> while (!list_empty(..))
> work->func();

This mean that every work->func() which may sleep delays cpu_down/up unpredictable,
not good. What about work->func which sleeps then re-queues itself? I guess we can
solve this, but this is what I said "other changes".

Also, lock_cpu_hotplug() should be per-cpu, otherwise we have livelock.

Not that I am against lock_cpu_hotplug (I can't judge), but its usage in run_workqueue
looks like complication to me. I may be wrong. But the main problem we don't have it :)

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/