Messages in this thread | | | Date | Thu, 15 Dec 2011 11:31:33 -0800 | From | Tejun Heo <> | Subject | Re: workqueue_set_max_active(wq, 0)? |
| |
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
| |