io_uring: provide fallback request for OOM situations
authorJens Axboe <axboe@kernel.dk>
Fri, 8 Nov 2019 15:52:53 +0000 (08:52 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 11 Nov 2019 23:32:55 +0000 (16:32 -0700)
commit0ddf92e848ab7abf216f218ee363eb9b9650e98f
tree795723a6285d9b89eb38d46298acf77d6fd8f8e0
parent8e3cca12706231daf8daf90dbde59f1665135e48
io_uring: provide fallback request for OOM situations

One thing that really sucks for userspace APIs is if the kernel passes
back -ENOMEM/-EAGAIN for resource shortages. The application really has
no idea of what to do in those cases. Should it try and reap
completions? Probably a good idea. Will it solve the issue? Who knows.

This patch adds a simple fallback mechanism if we fail to allocate
memory for a request. If we fail allocating memory from the slab for a
request, we punt to a pre-allocated request. There's just one of these
per io_ring_ctx, but the important part is if we ever return -EBUSY to
the application, the applications knows that it can wait for events and
make forward progress when events have completed. This is the important
part.

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