io_uring: use signal based task_work running
authorJens Axboe <axboe@kernel.dk>
Tue, 30 Jun 2020 18:39:05 +0000 (12:39 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 30 Jun 2020 18:39:05 +0000 (12:39 -0600)
commitce593a6c480a22acba08795be313c0c6d49dd35d
treea31b7d4e964ada0b9b768d405507c699dfef91b4
parente91b48162332480f5840902268108bb7fb7a44c7
io_uring: use signal based task_work running

Since 5.7, we've been using task_work to trigger async running of
requests in the context of the original task. This generally works
great, but there's a case where if the task is currently blocked
in the kernel waiting on a condition to become true, it won't process
task_work. Even though the task is woken, it just checks whatever
condition it's waiting on, and goes back to sleep if it's still false.

This is a problem if that very condition only becomes true when that
task_work is run. An example of that is the task registering an eventfd
with io_uring, and it's now blocked waiting on an eventfd read. That
read could depend on a completion event, and that completion event
won't get trigged until task_work has been run.

Use the TWA_SIGNAL notification for task_work, so that we ensure that
the task always runs the work when queued.

Cc: stable@vger.kernel.org # v5.7
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c