Skip to content

Commit

Permalink
io_uring/io-wq: don't gate worker wake up success on wake_up_process()
Browse files Browse the repository at this point in the history
All we really care about is finding a free worker. If said worker is
already running, it's either starting new work already or it's just
finishing up existing work. For the latter, we'll be finding this work
item next anyway, and for the former, if the worker does go to sleep,
it'll create a new worker anyway as we have pending items.

This reduces try_to_wake_up() overhead considerably:

23.16%    -10.46%  [kernel.kallsyms]      [k] try_to_wake_up

Reviewed-by: Hao Xu <howeyxu@tencent.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Aug 11, 2023
1 parent de36a15 commit 22f7fb8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions io_uring/io-wq.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,14 @@ static bool io_wq_activate_free_worker(struct io_wq *wq,
io_worker_release(worker);
continue;
}
if (wake_up_process(worker->task)) {
io_worker_release(worker);
return true;
}
/*
* If the worker is already running, it's either already
* starting work or finishing work. In either case, if it does
* to go sleep, we'll kick off a new task for this work anyway.
*/
wake_up_process(worker->task);
io_worker_release(worker);
return true;
}

return false;
Expand Down

0 comments on commit 22f7fb8

Please sign in to comment.