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>
Mon, 21 Apr 2025 11:13:28 +0000 (05:13 -0600)
commit37448b9de6d5f32948f5b64cfe866fa3d225afc2
tree4a1f8870c588de80288bbfc1cbb595992bd40d1b
parent169591106a957b21b4b04f84de3c8757d64aea72
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