Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350280
b: refs/heads/master
c: 9daf9e6
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo committed Jan 24, 2013
1 parent 121906a commit f094ad1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 715b06b864c99a18cb8368dfb187da4f569788cd
refs/heads/master: 9daf9e678d18585433a4ad90ec51a448e5fd054c
21 changes: 21 additions & 0 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ enum {

struct worker_pool {
struct global_cwq *gcwq; /* I: the owning gcwq */
int id; /* I: pool ID */
unsigned int flags; /* X: flags */

struct list_head worklist; /* L: list of pending works */
Expand Down Expand Up @@ -445,6 +446,10 @@ static atomic_t unbound_pool_nr_running[NR_STD_WORKER_POOLS] = {
[0 ... NR_STD_WORKER_POOLS - 1] = ATOMIC_INIT(0), /* always 0 */
};

/* idr of all pools */
static DEFINE_MUTEX(worker_pool_idr_mutex);
static DEFINE_IDR(worker_pool_idr);

static int worker_thread(void *__worker);
static unsigned int work_cpu(struct work_struct *work);

Expand All @@ -461,6 +466,19 @@ static struct global_cwq *get_gcwq(unsigned int cpu)
return &unbound_global_cwq;
}

/* allocate ID and assign it to @pool */
static int worker_pool_assign_id(struct worker_pool *pool)
{
int ret;

mutex_lock(&worker_pool_idr_mutex);
idr_pre_get(&worker_pool_idr, GFP_KERNEL);
ret = idr_get_new(&worker_pool_idr, pool, &pool->id);
mutex_unlock(&worker_pool_idr_mutex);

return ret;
}

static atomic_t *get_pool_nr_running(struct worker_pool *pool)
{
int cpu = pool->gcwq->cpu;
Expand Down Expand Up @@ -3830,6 +3848,9 @@ static int __init init_workqueues(void)

mutex_init(&pool->assoc_mutex);
ida_init(&pool->worker_ida);

/* alloc pool ID */
BUG_ON(worker_pool_assign_id(pool));
}
}

Expand Down

0 comments on commit f094ad1

Please sign in to comment.