Re: [PATCH 19/19] workqueue: implement concurrency managed workqueue

From: Tejun Heo
Date: Fri Oct 02 2009 - 08:04:24 EST


David Howells wrote:
> Tejun Heo <tj@xxxxxxxxxx> wrote:
>
>> gcwq always keeps at least single idle worker around. When a new
>> worker is necessary and the worker is the last idle one, the worker
>> assumes the role of "manager" and manages the worker pool -
>> ie. creates another worker. Forward-progress is guaranteed by having
>> dedicated rescue workers for workqueues which may be necessary while
>> creating a new worker. When the manager is having problem creating a
>> new worker, mayday timer activates and rescue workers are summoned to
>> the cpu and execute works which may be necessary to create new
>> workers.
>
> I take it that means that the rescue-workers are donated to the pool
> to become worker threads (perhaps on a temporary basis) in the event
> that forking fails due to ENOMEM, such that resources can be freed
> up for fork() to use.

Yes, when kthread_create() doesn't return fast enough
(MAYDAY_INITIAL_TIMEOUT, currently 10ms), rescue workers are summoned
to the cpu. They scan the pending works and process only the works
which are for the workqueue the rescuer is bound to which should solve
the possible allocation deadlock. Currently, all workqueues are
created with a rescuer by default but that will be changed as most of
them don't need it.

Thanks.

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