Re: Singlethread vs. freezable workqueues

Rafael J. Wysocki
2007-05-21T21:28:00Z

On Monday, 21 May 2007 22:54, Oleg Nesterov wrote:
> On 05/21, Rafael J. Wysocki wrote:
> >
> > On Monday, 21 May 2007 21:33, Alan Stern wrote:
> > > Raphael:
> > >
> > > Are we now committed to making freezable workqueues always
> > > singlethreaded? Is it at all likely to change back? Or should I
> > > introduce a "create_singlethread_freezeable_workqueue" macro?
> >
> > This was done as a quick fix of an issue with one driver that started to use
> > (broken) freezable workqueues when we were not watching. ;-)
> >
> > We are going to have multithread freezable workqueues as well, but that'll
> > take some time. We've discussed this a bit with Oleg and I believe he has an
> > idea of how it can be done cleanly.
>
> No, I don't have an idea how to do this cleanly currently.
>
> We can fix them right now with Rafael's "take_over_work() + migrate_sequence"
> patch, feel free to send it. Not perfect, but should work.

Well, there's no hurry with that, I think. If there's a clear case in which
such a workqueue would be useful, we can do this. For now, I don't see one.

> Perhaps it makes sense to make some other changes first. For example, kill
> CPU_TASKS_FROZEN bit.

That's possible, but the microcode driver uses it in a nontrivial way and that
should be taken into consideration.

> Next. We can't make all wqs freezeable, but if we add freezer_exempt/PF_FE_XXX
> we can freeze them all for cpu_up/cpu_down, this also make things simpler.

Yes.

> Note that we don't have a good way to use take_over_work() for !freezeable wq.
> 2.6.21 does kthread_stop() first, this is deadlockable because we may have
> a work_struct on ->worklist which also calls kthread_stop(). Perhaps it makes
> sense to wait until kthread_stop() will be reworked (should be soon).

Yes, I think we should wait until the kthread-related things settle.

> Perhaps we can think a bit more :)

Sure, that won't hurt. :-)

Greetings,
Rafael