Re: [RFC PATCHSET] workqueue: implement concurrency managed workqueue

Ingo Molnar
2009-10-01T08:41:40Z

* Tejun Heo <tj@kernel.org> wrote:

> Hello, all.
>
> This rather large patchset implements concurrency managed workqueue.
> It's not complete yet. Singlethread workqueue handling needs more
> work and workqueue users need to be audited and simplified and async
> and slow-work should be reimplemented in terms of workqueue. Although
> this patchset currently adds ~2000 lines of code, I'm fairly
> optimistic that after the whole conversion is done, it would be a net
> decrease in lines of code.
>
> This patchset reimplements workqueue such that it auto-regulates
> concurrency and thus relieves its users from the managing duty. It
> works by managing single shared pool of per-cpu workers and hooking
> into the scheduler to get notifications about workers going to sleep
> and waking up. Using the mechanism, workqueue implementation keeps
> track of the current level of concurrency and schedules only the
> necessary number of workers to keep the cpu occupied.

Ok, this looks fairly interesting - and the way you reused scheduler
classes to auto-regulate with no impact on regular performance is quite
an ingenious idea as well. (KVM's preempt notifiers should probably use
this trick too, instead of an ugly notifier in the scheduler hotpath)

This mechanism could be used to implement threadlets/syslets too btw.,
and other forms of asynchronous IO.

My main worry is that in practice workqueues arent all that performance
critical - so we are shooting to optimize something that doesnt
necessarily use all the potential goodness inherent in this approach.

Ingo