io_uring: don't submit sqes when ctx->refs is dying
authorXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Wed, 20 May 2020 07:35:03 +0000 (15:35 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 20 May 2020 14:41:26 +0000 (08:41 -0600)
commit6b668c9b7fc6fc0c313cdaee8b75d17f4d954ab5
tree2e3467201427f4f9fd45ceab17077f3aa5fafa10
parent310672552f4aea2ad50704711aa3cdd45f5441e9
io_uring: don't submit sqes when ctx->refs is dying

When IORING_SETUP_SQPOLL is enabled, io_ring_ctx_wait_and_kill() will wait
for sq thread to idle by busy loop:

    while (ctx->sqo_thread && !wq_has_sleeper(&ctx->sqo_wait))
        cond_resched();

Above loop isn't very CPU friendly, it may introduce a short cpu burst on
the current cpu.

If ctx->refs is dying, we forbid sq_thread from submitting any further
SQEs. Instead they just get discarded when we exit.

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c