diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2013-03-25 19:57:18 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-25 19:57:18 -0400 |
commit | 87fc741e94cf64445c698486982b30afa0811eca (patch) | |
tree | 2da27793071072983a69a8808c9c7dad4b0c568b /kernel/workqueue.c | |
parent | 3c25a55daadc7e7058926f5728fba7721d824ffb (diff) |
workqueue: protect wq->nr_drainers and ->flags 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.
wq->nr_drainers and ->flags are specific to each workqueue. Protect
->nr_drainers and ->flags with wq->mutex instead of pool_mutex.
tj: Rebased on top of the current dev branch. Updated description.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index d448edae3513..3ac2c4d85607 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -226,7 +226,7 @@ struct wq_device; | |||
226 | * the appropriate worker_pool through its pool_workqueues. | 226 | * the appropriate worker_pool through its pool_workqueues. |
227 | */ | 227 | */ |
228 | struct workqueue_struct { | 228 | struct workqueue_struct { |
229 | unsigned int flags; /* PL: WQ_* flags */ | 229 | unsigned int flags; /* WQ: WQ_* flags */ |
230 | struct pool_workqueue __percpu *cpu_pwqs; /* I: per-cpu pwq's */ | 230 | struct pool_workqueue __percpu *cpu_pwqs; /* I: per-cpu pwq's */ |
231 | struct list_head pwqs; /* WR: all pwqs of this wq */ | 231 | struct list_head pwqs; /* WR: all pwqs of this wq */ |
232 | struct list_head list; /* PL: list of all workqueues */ | 232 | struct list_head list; /* PL: list of all workqueues */ |
@@ -242,7 +242,7 @@ struct workqueue_struct { | |||
242 | struct list_head maydays; /* MD: pwqs requesting rescue */ | 242 | struct list_head maydays; /* MD: pwqs requesting rescue */ |
243 | struct worker *rescuer; /* I: rescue worker */ | 243 | struct worker *rescuer; /* I: rescue worker */ |
244 | 244 | ||
245 | int nr_drainers; /* PL: drain in progress */ | 245 | int nr_drainers; /* WQ: drain in progress */ |
246 | int saved_max_active; /* PW: saved pwq max_active */ | 246 | int saved_max_active; /* PW: saved pwq max_active */ |
247 | 247 | ||
248 | #ifdef CONFIG_SYSFS | 248 | #ifdef CONFIG_SYSFS |
@@ -2684,10 +2684,10 @@ void drain_workqueue(struct workqueue_struct *wq) | |||
2684 | * hotter than drain_workqueue() and already looks at @wq->flags. | 2684 | * hotter than drain_workqueue() and already looks at @wq->flags. |
2685 | * Use __WQ_DRAINING so that queue doesn't have to check nr_drainers. | 2685 | * Use __WQ_DRAINING so that queue doesn't have to check nr_drainers. |
2686 | */ | 2686 | */ |
2687 | mutex_lock(&wq_pool_mutex); | 2687 | mutex_lock(&wq->mutex); |
2688 | if (!wq->nr_drainers++) | 2688 | if (!wq->nr_drainers++) |
2689 | wq->flags |= __WQ_DRAINING; | 2689 | wq->flags |= __WQ_DRAINING; |
2690 | mutex_unlock(&wq_pool_mutex); | 2690 | mutex_unlock(&wq->mutex); |
2691 | reflush: | 2691 | reflush: |
2692 | flush_workqueue(wq); | 2692 | flush_workqueue(wq); |
2693 | 2693 | ||
@@ -2714,10 +2714,10 @@ reflush: | |||
2714 | 2714 | ||
2715 | local_irq_enable(); | 2715 | local_irq_enable(); |
2716 | 2716 | ||
2717 | mutex_lock(&wq_pool_mutex); | 2717 | mutex_lock(&wq->mutex); |
2718 | if (!--wq->nr_drainers) | 2718 | if (!--wq->nr_drainers) |
2719 | wq->flags &= ~__WQ_DRAINING; | 2719 | wq->flags &= ~__WQ_DRAINING; |
2720 | mutex_unlock(&wq_pool_mutex); | 2720 | mutex_unlock(&wq->mutex); |
2721 | } | 2721 | } |
2722 | EXPORT_SYMBOL_GPL(drain_workqueue); | 2722 | EXPORT_SYMBOL_GPL(drain_workqueue); |
2723 | 2723 | ||