workqueue: protect wq->pwqs and iteration with wq->mutex
authorLai Jiangshan <laijs@cn.fujitsu.com>
Mon, 25 Mar 2013 23:57:18 +0000 (16:57 -0700)
committerTejun Heo <tj@kernel.org>
Mon, 25 Mar 2013 23:57:18 +0000 (16:57 -0700)
commitb09f4fd39c0e562aff3682773f4c451d6125048c
treef96b59d02c0136f82c0d280bf6d075d6d0f48f9d
parent87fc741e94cf64445c698486982b30afa0811eca
workqueue: protect wq->pwqs and iteration with wq->mutex

We're expanding wq->mutex to cover all fields specific to each
workqueue with the end goal of replacing pwq_lock which will make
locking simpler and easier to understand.

init_and_link_pwq() and pwq_unbound_release_workfn() already grab
wq->mutex when adding or removing a pwq from wq->pwqs list.  This
patch makes it official that the list is wq->mutex protected for
writes and updates readers accoridingly.  Explicit IRQ toggles for
sched-RCU read-locking in flush_workqueue_prep_pwqs() and
drain_workqueues() are removed as the surrounding wq->mutex can
provide sufficient synchronization.

Also, assert_rcu_or_pwq_lock() is renamed to assert_rcu_or_wq_mutex()
and checks for wq->mutex too.

pwq_lock locking and assertion are not removed by this patch and a
couple of for_each_pwq() iterations are still protected by it.
They'll be removed by future patches.

tj: Rebased on top of the current dev branch.  Updated description.
    Folded in assert_rcu_or_wq_mutex() renaming from a later patch
    along with associated comment updates.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c