[PATCH 23/30] workqueue: use shared worklist and pool all workers per cpu

Date

Mon, 14 Jun 2010 23:37:40 +0200

Use gcwq->worklist instead of cwq->worklist and break the strictassociation between a cwq and its worker. All works queued on a cpuare queued on gcwq->worklist and processed by any available worker onthe gcwq.

As there no longer is strict association between a cwq and its worker,whether a work is executing can now only be determined by calling[__]find_worker_executing_work().

After this change, the only association between a cwq and its workeris that a cwq puts a worker into shared worker pool on creation andkills it on destruction. As all workqueues are still limited tomax_active of one, this means that there are always at least as manyworkers as active works and thus there's no danger for deadlock.

The break of strong association between cwqs and workers requiressomewhat clumsy changes to current_is_keventd() anddestroy_workqueue(). Dynamic worker pool management will remove bothclumsy changes. current_is_keventd() won't be necessary at all as theonly reason it exists is to avoid queueing a work from a work whichwill be allowed just fine. The clumsy part of destroy_workqueue() isadded because a worker can only be destroyed while idle and there's noguarantee a worker is idle when its wq is going down. With dynamicpool management, workers are not associated with workqueues at all andonly idle ones will be submitted to destroy_workqueue() so the codewon't be necessary anymore.