]> git.itanic.dy.fi Git - linux-stable/commit
io_uring/io-wq: stop setting PF_NO_SETAFFINITY on io-wq workers
authorJens Axboe <axboe@kernel.dk>
Wed, 8 Mar 2023 14:18:51 +0000 (07:18 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 8 Mar 2023 15:48:13 +0000 (08:48 -0700)
commit01e68ce08a30db3d842ce7a55f7f6e0474a55f9a
treeb2962dc88c9dcadbc042fa88f6442ffb40d34ae8
parentfe15c26ee26efa11741a7b632e9f23b01aca4cc6
io_uring/io-wq: stop setting PF_NO_SETAFFINITY on io-wq workers

Every now and then reports come in that are puzzled on why changing
affinity on the io-wq workers fails with EINVAL. This happens because they
set PF_NO_SETAFFINITY as part of their creation, as io-wq organizes
workers into groups based on what CPU they are running on.

However, this is purely an optimization and not a functional requirement.
We can allow setting affinity, and just lazily update our worker to wqe
mappings. If a given io-wq thread times out, it normally exits if there's
no more work to do. The exception is if it's the last worker available.
For the timeout case, check the affinity of the worker against group mask
and exit even if it's the last worker. New workers should be created with
the right mask and in the right location.

Reported-by:Daniel Dao <dqminh@cloudflare.com>
Link: https://lore.kernel.org/io-uring/CA+wXwBQwgxB3_UphSny-yAP5b26meeOu1W4TwYVcD_+5gOhvPw@mail.gmail.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io-wq.c