Skip to content

Commit ca9252f

Browse files
committed
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 <[email protected]> Link: #429 (comment) Signed-off-by: Jens Axboe <[email protected]>
1 parent 7faebb8 commit ca9252f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/queue.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
112112
flags = IORING_ENTER_GETEVENTS | data->get_flags;
113113
need_enter = true;
114114
}
115-
if (data->submit) {
116-
sq_ring_needs_enter(ring, &flags);
115+
if (data->submit && sq_ring_needs_enter(ring, &flags))
117116
need_enter = true;
118-
}
119117
if (!need_enter)
120118
break;
121119

0 commit comments

Comments
 (0)