Re: [PATCH 19/21] workqueue: introduce worker

From: Tejun Heo
Date: Tue Nov 17 2009 - 11:27:14 EST


Hello,

11/17/2009 08:51 PM, Louis Rilling wrote:
>>> +static struct worker *create_worker(struct cpu_workqueue_struct *cwq, bool bind)
>>> +{
>>> + int id = -1;
>>> + struct worker *worker = NULL;
>>> +
>>> + spin_lock(&workqueue_lock);
>>> + while (ida_get_new(&per_cpu(worker_ida, cwq->cpu), &id)) {
>>> + spin_unlock_irq(&workqueue_lock);
>>> + if (!ida_pre_get(&per_cpu(worker_ida, cwq->cpu), GFP_KERNEL))
>>> + goto fail;
>>> + spin_lock(&workqueue_lock);
>>> + }
>>> + spin_unlock_irq(&workqueue_lock);
>>> +
>>> + worker = alloc_worker();
>>> + if (!worker)
>>> + goto fail;
>>> +
>>> + worker->cwq = cwq;
>>> + worker->id = id;
>>> +
>>> + worker->task = kthread_create(worker_thread, worker, "kworker/%u:%d",
>>> + cwq->cpu, id);
>>> + if (IS_ERR(worker->task))
>>> + goto fail;
>>> +
>>> + if (bind)
>>> + kthread_bind(worker->task, cwq->cpu);
>>> +
>>> + return worker;
>>> +fail:
>>> + if (id >= 0) {
>>> + spin_lock(&workqueue_lock);
>>> + ida_remove(&per_cpu(worker_ida, cwq->cpu), id);
>>> + spin_unlock_irq(&workqueue_lock);
>>> + }
>>> + kfree(worker);
>>> + return NULL;
>>> +}
>>
>> AFAIU create_worker() should call spin_lock_irq() instead of spin_lock().
>
> spin_unlock() instead of spin_unlock_irq() looks better in fact ;).

Oooh... right, thanks for spotting that. I'll fix it up.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/