Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365537
b: refs/heads/master
c: a357fc0
h: refs/heads/master
i:
  365535: 2dea5ca
v: v3
  • Loading branch information
Lai Jiangshan authored and Tejun Heo committed Mar 25, 2013
1 parent c443319 commit ee3274e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b09f4fd39c0e562aff3682773f4c451d6125048c
refs/heads/master: a357fc03262988f2aa6c4a668b89be22b11ff1e7
33 changes: 16 additions & 17 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ struct workqueue_struct {
struct worker *rescuer; /* I: rescue worker */

int nr_drainers; /* WQ: drain in progress */
int saved_max_active; /* PW: saved pwq max_active */
int saved_max_active; /* WQ: saved pwq max_active */

#ifdef CONFIG_SYSFS
struct wq_device *wq_dev; /* I: for sysfs interface */
Expand Down Expand Up @@ -3579,13 +3579,13 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
bool freezable = wq->flags & WQ_FREEZABLE;

/* for @wq->saved_max_active */
lockdep_assert_held(&pwq_lock);
lockdep_assert_held(&wq->mutex);

/* fast exit for non-freezable wqs */
if (!freezable && pwq->max_active == wq->saved_max_active)
return;

spin_lock(&pwq->pool->lock);
spin_lock_irq(&pwq->pool->lock);

if (!freezable || !(pwq->pool->flags & POOL_FREEZING)) {
pwq->max_active = wq->saved_max_active;
Expand All @@ -3603,7 +3603,7 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
pwq->max_active = 0;
}

spin_unlock(&pwq->pool->lock);
spin_unlock_irq(&pwq->pool->lock);
}

static void init_and_link_pwq(struct pool_workqueue *pwq,
Expand All @@ -3622,7 +3622,6 @@ static void init_and_link_pwq(struct pool_workqueue *pwq,
INIT_WORK(&pwq->unbound_release_work, pwq_unbound_release_workfn);

mutex_lock(&wq->mutex);
spin_lock_irq(&pwq_lock);

/*
* Set the matching work_color. This is synchronized with
Expand All @@ -3636,9 +3635,10 @@ static void init_and_link_pwq(struct pool_workqueue *pwq,
pwq_adjust_max_active(pwq);

/* link in @pwq */
spin_lock_irq(&pwq_lock);
list_add_rcu(&pwq->pwqs_node, &wq->pwqs);

spin_unlock_irq(&pwq_lock);

mutex_unlock(&wq->mutex);
}

Expand Down Expand Up @@ -3803,10 +3803,10 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
*/
mutex_lock(&wq_pool_mutex);

spin_lock_irq(&pwq_lock);
mutex_lock(&wq->mutex);
for_each_pwq(pwq, wq)
pwq_adjust_max_active(pwq);
spin_unlock_irq(&pwq_lock);
mutex_unlock(&wq->mutex);

list_add(&wq->list, &workqueues);

Expand Down Expand Up @@ -3917,14 +3917,14 @@ void workqueue_set_max_active(struct workqueue_struct *wq, int max_active)

max_active = wq_clamp_max_active(max_active, wq->flags, wq->name);

spin_lock_irq(&pwq_lock);
mutex_lock(&wq->mutex);

wq->saved_max_active = max_active;

for_each_pwq(pwq, wq)
pwq_adjust_max_active(pwq);

spin_unlock_irq(&pwq_lock);
mutex_unlock(&wq->mutex);
}
EXPORT_SYMBOL_GPL(workqueue_set_max_active);

Expand Down Expand Up @@ -4287,7 +4287,7 @@ EXPORT_SYMBOL_GPL(work_on_cpu);
* pool->worklist.
*
* CONTEXT:
* Grabs and releases wq_pool_mutex, pwq_lock and pool->lock's.
* Grabs and releases wq_pool_mutex, wq->mutex and pool->lock's.
*/
void freeze_workqueues_begin(void)
{
Expand All @@ -4309,13 +4309,12 @@ void freeze_workqueues_begin(void)
spin_unlock_irq(&pool->lock);
}

/* suppress further executions by setting max_active to zero */
spin_lock_irq(&pwq_lock);
list_for_each_entry(wq, &workqueues, list) {
mutex_lock(&wq->mutex);
for_each_pwq(pwq, wq)
pwq_adjust_max_active(pwq);
mutex_unlock(&wq->mutex);
}
spin_unlock_irq(&pwq_lock);

mutex_unlock(&wq_pool_mutex);
}
Expand Down Expand Up @@ -4373,7 +4372,7 @@ bool freeze_workqueues_busy(void)
* frozen works are transferred to their respective pool worklists.
*
* CONTEXT:
* Grabs and releases wq_pool_mutex, pwq_lock and pool->lock's.
* Grabs and releases wq_pool_mutex, wq->mutex and pool->lock's.
*/
void thaw_workqueues(void)
{
Expand All @@ -4396,12 +4395,12 @@ void thaw_workqueues(void)
}

/* restore max_active and repopulate worklist */
spin_lock_irq(&pwq_lock);
list_for_each_entry(wq, &workqueues, list) {
mutex_lock(&wq->mutex);
for_each_pwq(pwq, wq)
pwq_adjust_max_active(pwq);
mutex_unlock(&wq->mutex);
}
spin_unlock_irq(&pwq_lock);

workqueue_freezing = false;
out_unlock:
Expand Down

0 comments on commit ee3274e

Please sign in to comment.