OSDN Git Service

io_uring: punt final io_ring_ctx wait-and-free to workqueue
authorJens Axboe <axboe@kernel.dk>
Fri, 10 Apr 2020 00:14:00 +0000 (18:14 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 10 Apr 2020 00:45:27 +0000 (18:45 -0600)
commit85faa7b8346ebef0606d2d0df6d3f8c76acb3654
tree5889b4560c5d4c6be271181d7d48dd350e88dd4a
parentc398ecb3d611925e4a5411afdf7489914a5c0460
io_uring: punt final io_ring_ctx wait-and-free to workqueue

We can't reliably wait in io_ring_ctx_wait_and_kill(), since the
task_works list isn't ordered (in fact it's LIFO ordered). We could
either fix this with a separate task_works list for io_uring work, or
just punt the wait-and-free to async context. This ensures that
task_work that comes in while we're shutting down is processed
correctly. If we don't go async, we could have work past the fput()
work for the ring that depends on work that won't be executed until
after we're done with the wait-and-free. But as this operation is
blocking, it'll never get a chance to run.

This was reproduced with hundreds of thousands of sockets running
memcached, haven't been able to reproduce this synthetically.

Reported-by: Dan Melnic <dmm@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c