workqueue: narrow the protection range of manager_mutex
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 20 May 2014 09:46:33 +0000 (17:46 +0800)
committerTejun Heo <tj@kernel.org>
Tue, 20 May 2014 14:59:32 +0000 (10:59 -0400)
commit4d757c5c81edba2052aae10d5b36dfcb9902b141
treecf6462421d19834ab6bdd17d18c7916a5adb8fb4
parent7cda9aae0596d871a8d7a6888d7b447c60e5ab30
workqueue: narrow the protection range of manager_mutex

In create_worker(), as pool->worker_ida now uses
ida_simple_get()/ida_simple_put() and doesn't require external
synchronization, it doesn't need manager_mutex.

struct worker allocation and kthread allocation are not visible by any
one before attached, so they don't need manager_mutex either.

The above operations are before the attaching operation which attaches
the worker to the pool. Between attaching and starting the worker, the
worker is already attached to the pool, so the cpu hotplug will handle
cpu-binding for the worker correctly and we don't need the
manager_mutex after attaching.

The conclusion is that only the attaching operation needs manager_mutex,
so we narrow the protection section of manager_mutex in create_worker().

Some comments about manager_mutex are removed, because we will rename
it to attach_mutex and add worker_attach_to_pool() later which will be
self-explanatory.

tj: Minor description updates.

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