On 5/21/24 12:25 PM, Jens Axboe wrote: > Outside of that, only other thing I can think of is that the final > close would be punted to task_work by fput(), which means there's also > a dependency on the task having run its kernel task_work before it's > fully closed. Yep I think that's it, the below should fix it. diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index 554c7212aa46..68a3e3290411 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -241,6 +241,8 @@ static unsigned int io_sq_tw(struct llist_node **retry_list, int max_entries) return count; max_entries -= count; } + if (task_work_pending(current)) + task_work_run(); *retry_list = tctx_task_work_run(tctx, max_entries, &count); return count; -- Jens Axboe