io_uring: add per-task callback handler
authorJens Axboe <axboe@kernel.dk>
Mon, 17 Feb 2020 16:52:41 +0000 (09:52 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 2 Mar 2020 21:06:36 +0000 (14:06 -0700)
commitb41e98524e424d104aa7851d54fd65820759875a
treeb17b6b59b0a11c6d0bc5836d835d68daa7e3373f
parentc2f2eb7d2c1cdc37fa9633bae96f381d33ee7a14
io_uring: add per-task callback handler

For poll requests, it's not uncommon to link a read (or write) after
the poll to execute immediately after the file is marked as ready.
Since the poll completion is called inside the waitqueue wake up handler,
we have to punt that linked request to async context. This slows down
the processing, and actually means it's faster to not use a link for this
use case.

We also run into problems if the completion_lock is contended, as we're
doing a different lock ordering than the issue side is. Hence we have
to do trylock for completion, and if that fails, go async. Poll removal
needs to go async as well, for the same reason.

eventfd notification needs special case as well, to avoid stack blowing
recursion or deadlocks.

These are all deficiencies that were inherited from the aio poll
implementation, but I think we can do better. When a poll completes,
simply queue it up in the task poll list. When the task completes the
list, we can run dependent links inline as well. This means we never
have to go async, and we can remove a bunch of code associated with
that, and optimizations to try and make that run faster. The diffstat
speaks for itself.

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