Thank you for review!
Yes, this is the same (old) problem as we have/had with flush_workqueue().
We can convert flush_work() to use preempt_disable (this is not straightforward,
but easy), or forbid to call flush_work() from work.func().
This patch doesn't touch this problem.
Hmm... This should not be possible? cwq->thread != NULL on CPU_DEAD event.
Event IF it was NULL, we don't call kthread_stop() in that case.
Could you clarify? I believe cwq->thread == current test always works, we never
"substitute" cwq->thread.
I still don't think this is a good idea. We also need
is_cpu_down_waits_for_lock_cpu_hotplug()
helper, otherwise we have a deadlock if work->func() sleeps and re-queues itself.
Yes, http://marc.theaimsgroup.com/?l=linux-kernel&m=116818097927685, I believe
we can do this later. This way workqueue will have almost zero interaction
with cpu-hotplug, and cpu UP/DOWN event won't be delayed by sleeping work.func().
take_over_work() can go away, this also allows us to simplify things.
Thanks!
Oleg.
-