Re: [PATCH 14/31] workqueue: replace POOL_MANAGING_WORKERS flag withworker_pool->manager_mutex

From: Tejun Heo
Date: Sun Mar 10 2013 - 08:46:41 EST


Hello, Lai.

On Sun, Mar 10, 2013 at 06:09:38PM +0800, Lai Jiangshan wrote:
> > - if (pool->flags & POOL_MANAGING_WORKERS)
> > + if (!mutex_trylock(&pool->manager_mutex))
> > return ret;
> >
> > - pool->flags |= POOL_MANAGING_WORKERS;
>
>
> if mutex_trylock(&pool->manager_mutex) fails, it does not mean
> the pool is managing workers. (although current code does).
> so I recommend to keep POOL_MANAGING_WORKERS.

So, that's the intention. It's gonna be used during pool destruction
and we want all the workers to think that the pool is being managed
and it's safe to proceed.

> I suggest that you reuse assoc_mutex for your purpose(later patches).
> (and rename assoc_mutex back to manager_mutex)

They are different. assoc_mutex makes the workers wait for the
managership, which shouldn't happen during pool destruction. We want
the workers to assume that the pool is managed which is what
manager_mutex achieves.

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/