From: Bijan Mottahedeh <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH liburing 3/3] remove duplicate call to __io_uring_peek_cqe()
Date: Tue, 19 May 2020 14:52:21 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Remove the __io_uring_peek_cqe() call from io_uring_wait_cqe_nr()
since the former is unconditionally called from io_uring_wait_cqe_nr()
-> __io_uring_get_cqe(). Also move __io_uring_get_cqe() together with
__io_uring_get_cqe() since that's now the only caller.
Signed-off-by: Bijan Mottahedeh <[email protected]>
---
src/include/liburing.h | 32 --------------------------------
src/queue.c | 27 +++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/include/liburing.h b/src/include/liburing.h
index dd85f7b..4311325 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -444,32 +444,6 @@ static inline unsigned io_uring_cq_ready(struct io_uring *ring)
return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
}
-static int __io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
-{
- struct io_uring_cqe *cqe;
- unsigned head;
- int err = 0;
-
- do {
- io_uring_for_each_cqe(ring, head, cqe)
- break;
- if (cqe) {
- if (cqe->user_data == LIBURING_UDATA_TIMEOUT) {
- if (cqe->res < 0)
- err = cqe->res;
- io_uring_cq_advance(ring, 1);
- if (!err)
- continue;
- cqe = NULL;
- }
- }
- break;
- } while (1);
-
- *cqe_ptr = cqe;
- return err;
-}
-
/*
* Return an IO completion, waiting for 'wait_nr' completions if one isn't
* readily available. Returns 0 with cqe_ptr filled in on success, -errno on
@@ -479,12 +453,6 @@ static inline int io_uring_wait_cqe_nr(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr,
unsigned wait_nr)
{
- int err;
-
- err = __io_uring_peek_cqe(ring, cqe_ptr);
- if (err || *cqe_ptr)
- return err;
-
return __io_uring_get_cqe(ring, cqe_ptr, 0, wait_nr, NULL);
}
diff --git a/src/queue.c b/src/queue.c
index da2f405..3db52bd 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -32,6 +32,33 @@ static inline bool sq_ring_needs_enter(struct io_uring *ring,
return false;
}
+static int __io_uring_peek_cqe(struct io_uring *ring,
+ struct io_uring_cqe **cqe_ptr)
+{
+ struct io_uring_cqe *cqe;
+ unsigned head;
+ int err = 0;
+
+ do {
+ io_uring_for_each_cqe(ring, head, cqe)
+ break;
+ if (cqe) {
+ if (cqe->user_data == LIBURING_UDATA_TIMEOUT) {
+ if (cqe->res < 0)
+ err = cqe->res;
+ io_uring_cq_advance(ring, 1);
+ if (!err)
+ continue;
+ cqe = NULL;
+ }
+ }
+ break;
+ } while (1);
+
+ *cqe_ptr = cqe;
+ return err;
+}
+
int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
unsigned submit, unsigned wait_nr, sigset_t *sigmask)
{
--
1.8.3.1
next prev parent reply other threads:[~2020-05-19 21:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 21:52 [PATCH liburing 0/3] __io_uring_get_cqe() fix/optimization Bijan Mottahedeh
2020-05-19 21:52 ` [PATCH liburing 1/3] preseve wait_nr if SETUP_IOPOLL is set Bijan Mottahedeh
2020-05-19 21:52 ` [PATCH liburing 2/3] update wait_nr to account for completed event Bijan Mottahedeh
2020-05-19 21:52 ` Bijan Mottahedeh [this message]
2020-05-19 22:12 ` [PATCH liburing 0/3] __io_uring_get_cqe() fix/optimization 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=1589925141-48552-4-git-send-email-bijan.mottahedeh@oracle.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