workqueue: remove the lock from wq_sysfs_prep_attrs()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Wed, 20 May 2015 06:41:18 +0000 (14:41 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 21 May 2015 21:26:22 +0000 (17:26 -0400)
Reading to wq->unbound_attrs requires protection of either wq_pool_mutex
or wq->mutex, and wq_sysfs_prep_attrs() is called with wq_pool_mutex held,
so we don't need to grab wq->mutex here.

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

index bd4b24d3489dac4fe93f2e026a298c327b567213..ad8dc2b9efc3786abddd6ba38e23b641e1e0daee 100644 (file)
@@ -4937,13 +4937,13 @@ static struct workqueue_attrs *wq_sysfs_prep_attrs(struct workqueue_struct *wq)
 {
        struct workqueue_attrs *attrs;
 
+       lockdep_assert_held(&wq_pool_mutex);
+
        attrs = alloc_workqueue_attrs(GFP_KERNEL);
        if (!attrs)
                return NULL;
 
-       mutex_lock(&wq->mutex);
        copy_workqueue_attrs(attrs, wq->unbound_attrs);
-       mutex_unlock(&wq->mutex);
        return attrs;
 }