On 4/11/25 7:55 AM, Christian Brauner wrote: > On Wed, Apr 09, 2025 at 07:35:20AM -0600, Jens Axboe wrote: >> 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 > > I was a bit surprised by this because it means that all those __fput()s > are done with kthread credentials which is a bit surprising (but > harmless afaict). Sure hope it is, because that's already what happens off the delayed fput that it'd otherwise go through! >> 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. > > Ok, so the only change is that this isn't offloaded to the global > delayed fput workqueue but to the task work that you're running off of > your kthread helpers. Exactly -- Jens Axboe