io_uring/io-wq: only create a new worker if it can make progress
authorJens Axboe <axboe@kernel.dk>
Fri, 23 May 2025 12:08:49 +0000 (06:08 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 23 May 2025 12:14:10 +0000 (06:14 -0600)
commit0b2b066f8a854ff485319f697d16c5f565c32112
tree316f77dc3de5783a8bd7b6a12ab652959b25c7e8
parent8343cae362e147a5d4505c2da0e161a4d9e9fbde
io_uring/io-wq: only create a new worker if it can make progress

Hashed work is serialized by io-wq, intended to be used for cases like
serializing buffered writes to a regular file, where the file system
will serialize the workers anyway with a mutex or similar. Since they
would be forcibly serialized and blocked, it's more efficient for io-wq
to handle these individually rather than issue them in parallel.

If a worker is currently handling a hashed work item and gets blocked,
don't create a new worker if the next work item is also hashed and
mapped to the same bucket. That new worker would not be able to make any
progress anyway.

Reported-by: Fengnan Chang <changfengnan@bytedance.com>
Reported-by: Diangang Li <lidiangang@bytedance.com>
Link: https://lore.kernel.org/io-uring/20250522090909.73212-1-changfengnan@bytedance.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io-wq.c