io_uring: add io_aux_cqe which allows deferred completion
authorDylan Yudaken <dylany@meta.com>
Thu, 24 Nov 2022 09:35:55 +0000 (01:35 -0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Nov 2022 13:10:04 +0000 (06:10 -0700)
commit9b8c54755a2b16d4f23c0ea184b75e2edf77d906
treef5084117ac5bfeca0b7ce2c50b8d276411bc5f6e
parent931147ddfa6e9ffd814272f1c0370c4740acbe17
io_uring: add io_aux_cqe which allows deferred completion

Use the just introduced deferred post cqe completion state when possible
in io_aux_cqe. If not possible fallback to io_post_aux_cqe.

This introduces a complication because of allow_overflow. For deferred
completions we cannot know without locking the completion_lock if it will
overflow (and even if we locked it, another post could sneak in and cause
this cqe to be in overflow).
However since overflow protection is mostly a best effort defence in depth
to prevent infinite loops of CQEs for poll, just checking the overflow bit
is going to be good enough and will result in at most 16 (array size of
deferred cqes) overflows.

Suggested-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Dylan Yudaken <dylany@meta.com>
Link: https://lore.kernel.org/r/20221124093559.3780686-6-dylany@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c
io_uring/io_uring.h
io_uring/net.c
io_uring/poll.c