Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365553
b: refs/heads/master
c: dce90d4
h: refs/heads/master
i:
  365551: f5c58de
v: v3
  • Loading branch information
Tejun Heo committed Apr 1, 2013
1 parent 58123ad commit 341be65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 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: 1befcf3073fa083e7dc48c384ce06f3bd900f514
refs/heads/master: dce90d47c4288c7d3c1988bebb059ea7451d5fd5
36 changes: 23 additions & 13 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,25 @@ static void put_pwq(struct pool_workqueue *pwq)
schedule_work(&pwq->unbound_release_work);
}

/**
* put_pwq_unlocked - put_pwq() with surrounding pool lock/unlock
* @pwq: pool_workqueue to put (can be %NULL)
*
* put_pwq() with locking. This function also allows %NULL @pwq.
*/
static void put_pwq_unlocked(struct pool_workqueue *pwq)
{
if (pwq) {
/*
* As both pwqs and pools are sched-RCU protected, the
* following lock operations are safe.
*/
spin_lock_irq(&pwq->pool->lock);
put_pwq(pwq);
spin_unlock_irq(&pwq->pool->lock);
}
}

static void pwq_activate_delayed_work(struct work_struct *work)
{
struct pool_workqueue *pwq = get_work_pwq(work);
Expand Down Expand Up @@ -3759,12 +3778,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,

mutex_unlock(&wq->mutex);

if (last_pwq) {
spin_lock_irq(&last_pwq->pool->lock);
put_pwq(last_pwq);
spin_unlock_irq(&last_pwq->pool->lock);
}

put_pwq_unlocked(last_pwq);
ret = 0;
/* fall through */
out_free:
Expand Down Expand Up @@ -3979,16 +3993,12 @@ void destroy_workqueue(struct workqueue_struct *wq)
} else {
/*
* We're the sole accessor of @wq at this point. Directly
* access the first pwq and put the base ref. As both pwqs
* and pools are sched-RCU protected, the lock operations
* are safe. @wq will be freed when the last pwq is
* released.
* access the first pwq and put the base ref. @wq will be
* freed when the last pwq is released.
*/
pwq = list_first_entry(&wq->pwqs, struct pool_workqueue,
pwqs_node);
spin_lock_irq(&pwq->pool->lock);
put_pwq(pwq);
spin_unlock_irq(&pwq->pool->lock);
put_pwq_unlocked(pwq);
}
}
EXPORT_SYMBOL_GPL(destroy_workqueue);
Expand Down

0 comments on commit 341be65

Please sign in to comment.