io_uring: add lazy poll_wq activation
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 9 Jan 2023 14:46:09 +0000 (14:46 +0000)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Jan 2023 17:25:35 +0000 (10:25 -0700)
commite05f6f47bf8aed0e97d9ba1d52e2a10ea542609c
treea58f1babe3700a0d12ec9880e58ed3cedcec4e7a
parent6b40f3c9a37b97e629a99a92d2c392d77ae20f60
io_uring: add lazy poll_wq activation

Even though io_poll_wq_wake()'s waitqueue_active reuses a barrier we do
for another waitqueue, it's not going to be the case in the future and
so we want to have a fast path for it when the ring has never been
polled.

Move poll_wq wake ups into __io_commit_cqring_flush() using a new flag
called ->poll_activated. The idea behind the flag is to set it when the
ring was polled for the first time. This requires additional sync to not
miss events, which is done here by using task_work for ->task_complete
rings, and by default enabling the flag for all other types of rings.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/060785e8e9137a920b232c0c7f575b131af19cac.1673274244.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
io_uring/io_uring.c
io_uring/io_uring.h