Re: [PATCH 2/2] workqueue: defer wake_up_process() outside pool->lock on hot paths

From: Sebastian Andrzej Siewior

Date: Wed May 27 2026 - 11:50:30 EST


On 2026-05-27 07:51:17 [-0700], Breno Leitao wrote:
> @@ -3447,7 +3459,13 @@ static int worker_thread(void *__worker)
> return 0;
> }
>
> - worker_leave_idle(worker);
> + /*
> + * Kicked workers have already been removed from pool->idle_list
> + * by kick_pool(); only first-time wakeups (via create_worker())
> + * still arrive with WORKER_IDLE set.
> + */
> + if (worker->flags & WORKER_IDLE)
> + worker_leave_idle(worker);

Couldn't create_worker() be aligned here not set the idle flag and wake
the thread a few lines later? Then we wouldn't have to conditionally
clear the idle flag here (which sort of NULL renders the flag check in
worker_leave_idle()).

> recheck:
> /* no more worker necessary? */
> if (!need_more_worker(pool))

Sebastian