Re: [PATCH 13/13] workqueue: record global worker ID instead of pool ID in work->data when off-queue

Tejun Heo
2013-02-04T21:41:03Z

Hello,

On Fri, Feb 01, 2013 at 02:41:36AM +0800, Lai Jiangshan wrote:
> - pool = worker_pool_by_id(pool_id);
> - if (!pool)
> - return NULL;
> + rcu_read_lock();
> + exec = idr_find(&worker_gwid_idr, worker_gwid);
>
> - spin_lock(&pool->lock);
> - exec = find_worker_executing_work(pool, work);
> if (exec) {
> - BUG_ON(pool != exec->pool);
> - *worker = exec;
> - return pool;
> + pool = exec->pool;
> + spin_lock(&pool->lock);
> + if (exec->current_work == work &&
> + exec->current_func == work->func) {
> + *worker = exec;
> + rcu_read_unlock();
> + return pool;
> + }
> + spin_unlock(&pool->lock);
> }
> - spin_unlock(&pool->lock);
> + rcu_read_unlock();

We're guaranteed to have irq disabled, why not use sched_rcu in
combination with synchronize_sched()?

Thanks.

--
tejun