Re: workqueue_set_max_active(wq, 0)?

From: Tejun Heo
Date: Thu Dec 15 2011 - 14:31:37 EST


Hello,

On Thu, Dec 15, 2011 at 08:26:01PM +0100, Johannes Berg wrote:
> Ah. So fundamentally, the freeze code does:
>
> * set each gcwq frozen
> * set max_active=0 for each CWQ in each WQ

Yeap and then iterate over them waiting for all nr_actives to drop to
zero.

> but it interleaves the two loops. I guess this would have to be
> untangled if we want to share it so it sets all gcwq frozen and then
> iterates the workqueues and their CWQs. Locking seems a bit hairy
> though, why does the current code keep the GCWQ lock over CWQ changes? I
> guess that's so nothing can work on the CWQ?

All CWQ's are protected by the corresponding GCWQ lock, so all CWQs on
the same CPU are protected by single gcwq->lock on that CPU. It's
actually rather simple. The reason the loop there is interleaved is
to avoid releasing and grabbing different gcwq->lock's for each
iteration. I don't think that would really matter either way.

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/