io_uring: mark exit side kworkers as task_work capable
authorJens Axboe <axboe@kernel.dk>
Tue, 4 Jun 2024 16:55:18 +0000 (10:55 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Jun 2024 17:13:55 +0000 (11:13 -0600)
commitb7fe5dfeb44fad432c6d8b8890f7ab8501e4a3a3
tree357a8a4ae4f85edb89f59a26275ec39bbdd144f9
parent8e2e7b4d1f57af86dd071f9e52446d407ac76164
io_uring: mark exit side kworkers as task_work capable

There are two types of work here:

1) Fallback work, if the task is exiting
2) The exit side cancelations

and both of them may do the final fput() of a file. When this happens,
fput() will schedule delayed work. This slows down exits when io_uring
needs to wait for that work to finish. It is possible to flush this via
flush_delayed_fput(), but that's a big hammer as other unrelated files
could be involved, and from other tasks as well.

Add two io_uring helpers to temporarily clear PF_NO_TASKWORK for the
worker threads, and run any queued task_work before setting the flag
again. Then we can ensure we only flush related items that received
their final fput as part of work cancelation and flushing.

For now these are io_uring private, but could obviously be made
generically available, should there be a need to do so.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c