From: Xiaoguang Wang <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Xiaoguang Wang <[email protected]>
Subject: [LIBURING PATCH] sq_ring_needs_enter: check whether there are sqes when SQPOLL is not enabled
Date: Mon, 13 Apr 2020 15:19:40 +0800 [thread overview]
Message-ID: <[email protected]> (raw)
Indeed I'm not sure this patch is necessary, robust applications
should not call io_uring_submit when there are not sqes to submmit.
But still try to add this check, I have seen some applications which
call io_uring_submit(), but there are not sqes to submit.
Signed-off-by: Xiaoguang Wang <[email protected]>
---
src/queue.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/queue.c b/src/queue.c
index e563775..75d707d 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -19,9 +19,10 @@
* or if IORING_SQ_NEED_WAKEUP is set, so submit thread must be explicitly
* awakened. For the latter case, we set the thread wakeup flag.
*/
-static inline bool sq_ring_needs_enter(struct io_uring *ring, unsigned *flags)
+static inline bool sq_ring_needs_enter(struct io_uring *ring,
+ unsigned submitted, unsigned *flags)
{
- if (!(ring->flags & IORING_SETUP_SQPOLL))
+ if (!(ring->flags & IORING_SETUP_SQPOLL) && submitted)
return true;
if (IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_NEED_WAKEUP) {
*flags |= IORING_ENTER_SQ_WAKEUP;
@@ -51,7 +52,7 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
if (wait_nr)
flags = IORING_ENTER_GETEVENTS;
if (submit)
- sq_ring_needs_enter(ring, &flags);
+ sq_ring_needs_enter(ring, submit, &flags);
if (wait_nr || submit)
ret = __sys_io_uring_enter(ring->ring_fd, submit,
wait_nr, flags, sigmask);
@@ -197,7 +198,7 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted,
int ret;
flags = 0;
- if (sq_ring_needs_enter(ring, &flags) || wait_nr) {
+ if (sq_ring_needs_enter(ring, submitted, &flags) || wait_nr) {
if (wait_nr || (ring->flags & IORING_SETUP_IOPOLL))
flags |= IORING_ENTER_GETEVENTS;
--
2.17.2
next reply other threads:[~2020-04-13 7:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-13 7:19 Xiaoguang Wang [this message]
2020-04-13 14:18 ` [LIBURING PATCH] sq_ring_needs_enter: check whether there are sqes when SQPOLL is not enabled Jens Axboe
2020-04-13 15:46 ` Hrvoje Zeba
2020-04-13 15:59 ` Jens Axboe
2020-04-13 22:27 ` 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=20200413071940.5156-1-xiaoguang.wang@linux.alibaba.com \
[email protected] \
[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