From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 2/5] src/queue: control kernel enter with a var
Date: Thu, 11 Feb 2021 23:08:13 +0000 [thread overview]
Message-ID: <0ce4c042da621e8f305ad8063e548192ffbea7a0.1613084222.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
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 <[email protected]>
---
src/queue.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/queue.c b/src/queue.c
index c2facfd..4fb4ea7 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -92,6 +92,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;
@@ -107,12 +108,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,
--
2.24.0
next prev parent reply other threads:[~2021-02-11 23:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 23:08 [PATCH liburing 0/5] segfault and not only fixes Pavel Begunkov
2021-02-11 23:08 ` [PATCH liburing 1/5] src/queue: don't re-wait for CQEs Pavel Begunkov
2021-02-11 23:08 ` Pavel Begunkov [this message]
2021-02-11 23:08 ` [PATCH liburing 3/5] test/link-timeout: close pipes after yourself Pavel Begunkov
2021-02-11 23:08 ` [PATCH liburing 4/5] test/sq-poll-share: don't ignore wait errors Pavel Begunkov
2021-02-11 23:08 ` [PATCH liburing 5/5] src/queue: fix no-error with NULL cqe Pavel Begunkov
2021-02-11 23:10 ` [PATCH liburing 0/5] segfault and not only fixes Pavel Begunkov
2021-02-11 23:45 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ce4c042da621e8f305ad8063e548192ffbea7a0.1613084222.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox