io_uring/io-wq: ignore non-busy worker going to sleep

When an io-wq worker goes to sleep, it checks if there's work to do.
If there is, it'll create a new worker. But if this worker is currently
idle, it'll either get woken right back up immediately, or someone
else has already created the necessary worker to handle this work.

Only go through the worker creation logic if the current worker is
currently handling a work item. That means it's being scheduled out as
part of handling that work, not just going to sleep on its own.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
pull/1250/head
Jens Axboe 2025-05-23 06:05:37 -06:00
parent e37dfc0530
commit 8343cae362
1 changed files with 2 additions and 0 deletions

View File

@ -429,6 +429,8 @@ static void io_wq_dec_running(struct io_worker *worker)
if (!atomic_dec_and_test(&acct->nr_running)) if (!atomic_dec_and_test(&acct->nr_running))
return; return;
if (!worker->cur_work)
return;
if (!io_acct_run_queue(acct)) if (!io_acct_run_queue(acct))
return; return;