src/queue: only enter the kernel if both submit and need_enter are true

We just take the submit count, and then unconditionally just call
sq_ring_needs_enter() to ensure that flags are set appropriately. Only
set need_enter for the submit side if sq_ring_needs_enter() is true,
which may not be the case if SQPOLL is used.

This can avoid a system call if we're not waiting on any CQEs, and
the thread is already running.

Reported-by: Olivier Langlois <olivier@trillion01.com>
Link: https://github.com/axboe/liburing/issues/429#issuecomment-926069364
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2021-09-23 15:19:31 -06:00
parent 0511578c5b
commit 5b04178b4e
+1 -3
View File
@@ -112,10 +112,8 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
flags = IORING_ENTER_GETEVENTS | data->get_flags;
need_enter = true;
}
if (data->submit) {
sq_ring_needs_enter(ring, &flags);
if (data->submit && sq_ring_needs_enter(ring, &flags))
need_enter = true;
}
if (!need_enter)
break;