From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Roman Penyaev <rpenyaev@suse.de>
Subject: [PATCH liburing 1/2] __io_uring_get_cqe(): Use io_uring_for_each_cqe()
Date: Mon, 1 Jul 2019 14:42:31 -0700 [thread overview]
Message-ID: <20190701214232.29338-2-bvanassche@acm.org> (raw)
In-Reply-To: <20190701214232.29338-1-bvanassche@acm.org>
Use io_uring_for_each_cqe() inside __io_uring_get_cqe() such that it
becomes possible to test the io_uring_for_each_cqe() implementation
from inside the liburing project.
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Roman Penyaev <rpenyaev@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
src/queue.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/src/queue.c b/src/queue.c
index 85e0c1e0d10f..bec363fc0ebf 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -14,26 +14,14 @@
static int __io_uring_get_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr, int wait)
{
- struct io_uring_cq *cq = &ring->cq;
- const unsigned mask = *cq->kring_mask;
unsigned head;
int ret;
- *cqe_ptr = NULL;
- head = *cq->khead;
do {
- /*
- * It's necessary to use a read_barrier() before reading
- * the CQ tail, since the kernel updates it locklessly. The
- * kernel has the matching store barrier for the update. The
- * kernel also ensures that previous stores to CQEs are ordered
- * with the tail update.
- */
- read_barrier();
- if (head != *cq->ktail) {
- *cqe_ptr = &cq->cqes[head & mask];
+ io_uring_for_each_cqe(ring, head, *cqe_ptr)
+ break;
+ if (*cqe_ptr)
break;
- }
if (!wait)
break;
ret = io_uring_enter(ring->ring_fd, 0, 1,
--
2.22.0.410.gd8fdbe21b5-goog
next prev parent reply other threads:[~2019-07-01 21:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 21:42 [PATCH liburing 0/2] Memory synchronization improvements Bart Van Assche
2019-07-01 21:42 ` Bart Van Assche [this message]
2019-07-01 21:42 ` [PATCH liburing 2/2] Fix the use of memory barriers Bart Van Assche
2019-07-02 9:07 ` Roman Penyaev
2019-07-02 16:17 ` Bart Van Assche
2019-07-02 18:40 ` Roman Penyaev
2019-07-02 20:31 ` Bart Van Assche
2019-07-03 9:49 ` Roman Penyaev
2019-07-03 20:49 ` Bart Van Assche
2019-07-02 16:18 ` [PATCH liburing 0/2] Memory synchronization improvements 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=20190701214232.29338-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=rpenyaev@suse.de \
--cc=stefanha@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).