Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365517
b: refs/heads/master
c: ebf44d1
h: refs/heads/master
i:
  365515: 837aeea
v: v3
  • Loading branch information
Tejun Heo committed Mar 14, 2013
1 parent cf2e84b commit 7dcb31b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 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: bc3a1afc92aea46d6df18d38e5d15867b17c69f6
refs/heads/master: ebf44d16ec4619c8a8daeacd987dd86d420ea2c3
47 changes: 23 additions & 24 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,26 @@ static void start_worker(struct worker *worker)
wake_up_process(worker->task);
}

/**
* create_and_start_worker - create and start a worker for a pool
* @pool: the target pool
*
* Create and start a new worker for @pool.
*/
static int create_and_start_worker(struct worker_pool *pool)
{
struct worker *worker;

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

return worker ? 0 : -ENOMEM;
}

/**
* destroy_worker - destroy a workqueue worker
* @worker: worker to be destroyed
Expand Down Expand Up @@ -3542,7 +3562,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
static DEFINE_MUTEX(create_mutex);
u32 hash = wqattrs_hash(attrs);
struct worker_pool *pool;
struct worker *worker;

mutex_lock(&create_mutex);

Expand All @@ -3568,14 +3587,9 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
goto fail;

/* create and start the initial worker */
worker = create_worker(pool);
if (!worker)
if (create_and_start_worker(pool) < 0)
goto fail;

spin_lock_irq(&pool->lock);
start_worker(worker);
spin_unlock_irq(&pool->lock);

/* install */
spin_lock_irq(&workqueue_lock);
hash_add(unbound_pool_hash, &pool->hash_node, hash);
Expand Down Expand Up @@ -4148,18 +4162,10 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
for_each_cpu_worker_pool(pool, cpu) {
struct worker *worker;

if (pool->nr_workers)
continue;

worker = create_worker(pool);
if (!worker)
if (create_and_start_worker(pool) < 0)
return NOTIFY_BAD;

spin_lock_irq(&pool->lock);
start_worker(worker);
spin_unlock_irq(&pool->lock);
}
break;

Expand Down Expand Up @@ -4409,15 +4415,8 @@ static int __init init_workqueues(void)
struct worker_pool *pool;

for_each_cpu_worker_pool(pool, cpu) {
struct worker *worker;

pool->flags &= ~POOL_DISASSOCIATED;

worker = create_worker(pool);
BUG_ON(!worker);
spin_lock_irq(&pool->lock);
start_worker(worker);
spin_unlock_irq(&pool->lock);
BUG_ON(create_and_start_worker(pool) < 0);
}
}

Expand Down

0 comments on commit 7dcb31b

Please sign in to comment.