Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365518
b: refs/heads/master
c: cd54968
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo committed Mar 14, 2013
1 parent 7dcb31b commit 8af47e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 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: ebf44d16ec4619c8a8daeacd987dd86d420ea2c3
refs/heads/master: cd549687a7ee5e619a26f55af4059c4ae585811c
13 changes: 12 additions & 1 deletion trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,8 @@ static struct worker *create_worker(struct worker_pool *pool)
struct worker *worker = NULL;
int id = -1;

lockdep_assert_held(&pool->manager_mutex);

spin_lock_irq(&pool->lock);
while (ida_get_new(&pool->worker_ida, &id)) {
spin_unlock_irq(&pool->lock);
Expand Down Expand Up @@ -1796,19 +1798,23 @@ static void start_worker(struct worker *worker)
* create_and_start_worker - create and start a worker for a pool
* @pool: the target pool
*
* Create and start a new worker for @pool.
* Grab the managership of @pool and create and start a new worker for it.
*/
static int create_and_start_worker(struct worker_pool *pool)
{
struct worker *worker;

mutex_lock(&pool->manager_mutex);

worker = create_worker(pool);
if (worker) {
spin_lock_irq(&pool->lock);
start_worker(worker);
spin_unlock_irq(&pool->lock);
}

mutex_unlock(&pool->manager_mutex);

return worker ? 0 : -ENOMEM;
}

Expand All @@ -1826,6 +1832,9 @@ static void destroy_worker(struct worker *worker)
struct worker_pool *pool = worker->pool;
int id = worker->id;

lockdep_assert_held(&pool->manager_mutex);
lockdep_assert_held(&pool->lock);

/* sanity check frenzy */
if (WARN_ON(worker->current_work) ||
WARN_ON(!list_empty(&worker->scheduled)))
Expand Down Expand Up @@ -3531,13 +3540,15 @@ static void put_unbound_pool(struct worker_pool *pool)
* manager_mutex.
*/
mutex_lock(&pool->manager_arb);
mutex_lock(&pool->manager_mutex);
spin_lock_irq(&pool->lock);

while ((worker = first_worker(pool)))
destroy_worker(worker);
WARN_ON(pool->nr_workers || pool->nr_idle);

spin_unlock_irq(&pool->lock);
mutex_unlock(&pool->manager_mutex);
mutex_unlock(&pool->manager_arb);

/* shut down the timers */
Expand Down

0 comments on commit 8af47e9

Please sign in to comment.