Re: [PATCH] workqueue: make manage_workers() and pool destruction exclusive

From: Tejun Heo
Date: Mon Mar 19 2018 - 11:27:59 EST


On Mon, Mar 19, 2018 at 03:35:07PM +0800, Lai Jiangshan wrote:
> The original code allows destroying the pool when the pool
> is still active in manage_workers(). A synchronization
> mechanism between manage_workers() and pool destruction
> was added for protection.
>
> This patch simply makes manage_workers() and pool destruction
> exclusive by getting an indirect refcount of the pool in
> manage_workers(). "indirect" means it gets a refcount of
> the first involved pwq which holds a refcount of the pool.
> This refcount can prevent the pool from being destroyed.
>
> The original synchronization mechanism (wq_manager_wait)
> is also removed.

Hmm... idk, this is more indirect and subtle than the existing code
and it's not like the existing code was overly complicated.

Thanks.

--
tejun