Re: [PATCH 04/10] workqueue: destroy worker directly in the idle timeout handler

Tejun Heo
2014-05-07T15:37:27Z

Hello, Lai.

On Wed, May 07, 2014 at 11:30:35PM +0800, Lai Jiangshan wrote:
> > Hah? How much extra complexity are we talking about? It's a single
> > if, no?
>
> DECLARE_COMPLETION_ONSTACK(completion);
> #1
>
> ...
>
> while ((worker = first_worker(pool))) {
> destroy_worker(worker);
> pool->detach_completion = &completion;
> #2
> }
>
> ...
> unlock;
>
> if (pool->detach_completion)
> wait_for_completion();
> #3
>
> One thing is separated into 3 places and about 5~7lines.
> I hope a single wait_for_completion() or single wait_event().

This is negligible amount of complexity contained in a single
function.

> get_unbound_pool():
> fail:
> if (pool)
> put_unbound_pool(pool);
>
> I think we can change it into:
>
> fail:
> if (pool) {
> if (pool->id >= 0)
> idr_remove(&worker_pool_idr, pool->id);
> call_rcu_sched(&pool->rcu, rcu_free_pool);
> }

This is destruction logic unnecessarily duplicated in two places,
which is shittier to maintain when the destruction path changes.

There's more to complexity than simple number of lines. It sure is a
minute difference here but I find the obsessions with LOC a bit
disturbing. That's just one aspect and involving more lines doesn't
necessarily mean it's more complex.

Thanks.

--
tejun