History

workqueue: make workqueue_lock irq-safe

workqueue_lock will be used to synchronize areas which require irq-safety and there isn't much benefit in keeping it not irq-safe. Make it irq-safe. This patch doesn't introduce any visible behavior changes.

Tejun Heo committed 13 years ago

Commit e98d5b11 parent 6183c001 file · +22 −22Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+22−22
@@ -2715,10 +2715,10 @@ void drain_workqueue(struct workqueue_struct *wq) · 2714 unmodified lines
27152715 * hotter than drain_workqueue() and already looks at @wq->flags.
27162716 * Use WQ_DRAINING so that queue doesn't have to check nr_drainers.
27172717 */
2718− spin_lock(&workqueue_lock);
2718+ spin_lock_irq(&workqueue_lock);
27192719 if (!wq->nr_drainers++)
27202720 wq->flags |= WQ_DRAINING;
2721− spin_unlock(&workqueue_lock);
2721+ spin_unlock_irq(&workqueue_lock);
27222722 reflush:
27232723 flush_workqueue(wq);
27242724
@@ -2740,10 +2740,10 @@ reflush: · 15 unmodified lines
27402740 goto reflush;
27412741 }
27422742
2743− spin_lock(&workqueue_lock);
2743+ spin_lock_irq(&workqueue_lock);
27442744 if (!--wq->nr_drainers)
27452745 wq->flags &= ~WQ_DRAINING;
2746− spin_unlock(&workqueue_lock);
2746+ spin_unlock_irq(&workqueue_lock);
27472747 }
27482748 EXPORT_SYMBOL_GPL(drain_workqueue);
27492749
@@ -3233,7 +3233,7 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, · 483 unmodified lines
32333233 * list. Grab it, set max_active accordingly and add the new
32343234 * workqueue to workqueues list.
32353235 */
3236− spin_lock(&workqueue_lock);
3236+ spin_lock_irq(&workqueue_lock);
32373237
32383238 if (workqueue_freezing && wq->flags & WQ_FREEZABLE)
32393239 for_each_pwq_cpu(cpu, wq)
@@ -3241,7 +3241,7 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, · 1 unmodified line
32413241
32423242 list_add(&wq->list, &workqueues);
32433243
3244− spin_unlock(&workqueue_lock);
3244+ spin_unlock_irq(&workqueue_lock);
32453245
32463246 return wq;
32473247 err:
@@ -3285,9 +3285,9 @@ void destroy_workqueue(struct workqueue_struct *wq) · 37 unmodified lines
32853285 * wq list is used to freeze wq, remove from list after
32863286 * flushing is complete in case freeze races us.
32873287 */
3288− spin_lock(&workqueue_lock);
3288+ spin_lock_irq(&workqueue_lock);
32893289 list_del(&wq->list);
3290− spin_unlock(&workqueue_lock);
3290+ spin_unlock_irq(&workqueue_lock);
32913291
32923292 if (wq->flags & WQ_RESCUER) {
32933293 kthread_stop(wq->rescuer->task);
@@ -3336,7 +3336,7 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) · 42 unmodified lines
33363336
33373337 max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);
33383338
3339− spin_lock(&workqueue_lock);
3339+ spin_lock_irq(&workqueue_lock);
33403340
33413341 wq->saved_max_active = max_active;
33423342
@@ -3344,16 +3344,16 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active) · 1 unmodified line
33443344 struct pool_workqueue *pwq = get_pwq(cpu, wq);
33453345 struct worker_pool *pool = pwq->pool;
33463346
3347− spin_lock_irq(&pool->lock);
3347+ spin_lock(&pool->lock);
33483348
33493349 if (!(wq->flags & WQ_FREEZABLE) ||
33503350 !(pool->flags & POOL_FREEZING))
33513351 pwq_set_max_active(pwq, max_active);
33523352
3353− spin_unlock_irq(&pool->lock);
3353+ spin_unlock(&pool->lock);
33543354 }
33553355
3356− spin_unlock(&workqueue_lock);
3356+ spin_unlock_irq(&workqueue_lock);
33573357 }
33583358 EXPORT_SYMBOL_GPL(workqueue_set_max_active);
33593359
@@ -3599,7 +3599,7 @@ void freeze_workqueues_begin(void) · 239 unmodified lines
35993599 {
36003600 unsigned int cpu;
36013601
3602− spin_lock(&workqueue_lock);
3602+ spin_lock_irq(&workqueue_lock);
36033603
36043604 WARN_ON_ONCE(workqueue_freezing);
36053605 workqueue_freezing = true;
@@ -3609,7 +3609,7 @@ void freeze_workqueues_begin(void) · 3 unmodified lines
36093609 struct workqueue_struct *wq;
36103610
36113611 for_each_std_worker_pool(pool, cpu) {
3612− spin_lock_irq(&pool->lock);
3612+ spin_lock(&pool->lock);
36133613
36143614 WARN_ON_ONCE(pool->flags & POOL_FREEZING);
36153615 pool->flags |= POOL_FREEZING;
@@ -3622,11 +3622,11 @@ void freeze_workqueues_begin(void) · 6 unmodified lines
36223622 pwq->max_active = 0;
36233623 }
36243624
3625− spin_unlock_irq(&pool->lock);
3625+ spin_unlock(&pool->lock);
36263626 }
36273627 }
36283628
3629− spin_unlock(&workqueue_lock);
3629+ spin_unlock_irq(&workqueue_lock);
36303630 }
36313631
36323632 /**
@@ -3647,7 +3647,7 @@ bool freeze_workqueues_busy(void) · 14 unmodified lines
36473647 unsigned int cpu;
36483648 bool busy = false;
36493649
3650− spin_lock(&workqueue_lock);
3650+ spin_lock_irq(&workqueue_lock);
36513651
36523652 WARN_ON_ONCE(!workqueue_freezing);
36533653
@@ -3671,7 +3671,7 @@ bool freeze_workqueues_busy(void) · 17 unmodified lines
36713671 }
36723672 }
36733673 out_unlock:
3674− spin_unlock(&workqueue_lock);
3674+ spin_unlock_irq(&workqueue_lock);
36753675 return busy;
36763676 }
36773677
@@ -3688,7 +3688,7 @@ void thaw_workqueues(void) · 10 unmodified lines
36883688 {
36893689 unsigned int cpu;
36903690
3691− spin_lock(&workqueue_lock);
3691+ spin_lock_irq(&workqueue_lock);
36923692
36933693 if (!workqueue_freezing)
36943694 goto out_unlock;
@@ -3698,7 +3698,7 @@ void thaw_workqueues(void) · 3 unmodified lines
36983698 struct workqueue_struct *wq;
36993699
37003700 for_each_std_worker_pool(pool, cpu) {
3701− spin_lock_irq(&pool->lock);
3701+ spin_lock(&pool->lock);
37023702
37033703 WARN_ON_ONCE(!(pool->flags & POOL_FREEZING));
37043704 pool->flags &= ~POOL_FREEZING;
@@ -3716,13 +3716,13 @@ void thaw_workqueues(void) · 11 unmodified lines
37163716
37173717 wake_up_worker(pool);
37183718
3719− spin_unlock_irq(&pool->lock);
3719+ spin_unlock(&pool->lock);
37203720 }
37213721 }
37223722
37233723 workqueue_freezing = false;
37243724 out_unlock:
3725− spin_unlock(&workqueue_lock);
3725+ spin_unlock_irq(&workqueue_lock);
37263726 }
37273727 #endif /* CONFIG_FREEZER */
37283728