Skip to content

Commit

Permalink
src/queue: only enter the kernel if both submit and need_enter are true
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: #429 (comment)
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Sep 23, 2021
1 parent 7faebb8 commit ca9252f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ca9252f

Please sign in to comment.