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>
Thu, 27 Feb 2020 21:21:22 +0000 (14:21 -0700)
commit9b5b91c6a0a59b5b0627a0153689a03093267591
treed0959c81ff285638b956caf1fdf369473748149f
parent6e09bc1fa94a00cb9bfcb111f1b0203574a551da
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