From ca9252f5f83d2497fa56aea559c774763b39ac4b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 23 Sep 2021 15:19:31 -0600 Subject: [PATCH] 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 Link: https://github.com/axboe/liburing/issues/429#issuecomment-926069364 Signed-off-by: Jens Axboe --- src/queue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/queue.c b/src/queue.c index 5d2c2a588..10ef31c28 100644 --- a/src/queue.c +++ b/src/queue.c @@ -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;