summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-02-11 23:08:13 +0000
committerJens Axboe <axboe@kernel.dk>2021-02-11 16:43:44 -0700
commit516e913eaeec0add5213dc7d0ea38c61fd2b80b6 (patch)
tree0fd5600fc70d4bbd2fcf3310a6eb4d13629a848d
parent51e6622bbe53f4957bbf3b4cfccf02b5139bb1ea (diff)
downloadliburing-516e913eaeec0add5213dc7d0ea38c61fd2b80b6.tar.gz
liburing-516e913eaeec0add5213dc7d0ea38c61fd2b80b6.tar.bz2
src/queue: control kernel enter with a var
We check twice for all entering conditions in _io_uring_get_cqe(), first to set flags, and the second to potentially break the loop. Save it into a need_enter var. Also, don't set IORING_ENTER_GETEVENTS when there is already enough of events in the CQ. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/queue.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/queue.c b/src/queue.c
index 14fee42..a688b43 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -93,6 +93,7 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
int err;
do {
+ bool need_enter = false;
bool cq_overflow_flush = false;
unsigned flags = 0;
unsigned nr_available;
@@ -108,12 +109,15 @@ static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_pt
}
cq_overflow_flush = true;
}
- if (data->wait_nr || cq_overflow_flush)
+ if (data->wait_nr > nr_available || cq_overflow_flush) {
flags = IORING_ENTER_GETEVENTS | data->get_flags;
- if (data->submit)
+ need_enter = true;
+ }
+ if (data->submit) {
sq_ring_needs_enter(ring, &flags);
- if (data->wait_nr <= nr_available && !data->submit &&
- !cq_overflow_flush)
+ need_enter = true;
+ }
+ if (!need_enter)
break;
ret = __sys_io_uring_enter2(ring->ring_fd, data->submit,