public inbox for [email protected]
 help / color / mirror / Atom feed
From: Dylan Yudaken <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>,
	Dylan Yudaken <[email protected]>
Subject: [PATCH liburing] fix test_buf_select_pipe on older kernels
Date: Mon, 4 Jul 2022 09:06:14 -0700	[thread overview]
Message-ID: <[email protected]> (raw)

timing issues might cause out of order completes on older kernels,
especially regarding selecting a buffer before queueing up IO (as it can
complete with ENOBUFS being queued).
Theres no reason to test ENOBUFS for this problem, so remove those checks.

Signed-off-by: Dylan Yudaken <[email protected]>
---
 test/read-write.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/test/read-write.c b/test/read-write.c
index eadeb78..c5cc469 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -428,28 +428,25 @@ static int test_buf_select_short(const char *filename, int nonvec)
 	return ret;
 }
 
-static int provide_buffers_iovec(struct io_uring *ring, int bgid, int count)
+static int provide_buffers_iovec(struct io_uring *ring, int bgid)
 {
 	struct io_uring_sqe *sqe;
 	struct io_uring_cqe *cqe;
 	int i, ret;
 
-	if (count <= 0)
-		count = BUFFERS;
-
-	for (i = 0; i < count; i++) {
+	for (i = 0; i < BUFFERS; i++) {
 		sqe = io_uring_get_sqe(ring);
 		io_uring_prep_provide_buffers(sqe, vecs[i].iov_base,
 						vecs[i].iov_len, 1, bgid, i);
 	}
 
 	ret = io_uring_submit(ring);
-	if (ret != count) {
+	if (ret != BUFFERS) {
 		fprintf(stderr, "submit: %d\n", ret);
 		return -1;
 	}
 
-	for (i = 0; i < count; i++) {
+	for (i = 0; i < BUFFERS; i++) {
 		ret = io_uring_wait_cqe(ring, &cqe);
 		if (ret) {
 			fprintf(stderr, "wait_cqe=%d\n", ret);
@@ -482,7 +479,7 @@ static int test_buf_select_pipe(void)
 		return 1;
 	}
 
-	ret = provide_buffers_iovec(&ring, 0, 4);
+	ret = provide_buffers_iovec(&ring, 0);
 	if (ret) {
 		fprintf(stderr, "provide buffers failed: %d\n", ret);
 		return 1;
@@ -515,13 +512,6 @@ static int test_buf_select_pipe(void)
 			fprintf(stderr, "bad wait %d\n", i);
 			return 1;
 		}
-		if (i == 4) {
-			if (cqe->res != -ENOBUFS) {
-				fprintf(stderr, "expected failure %d\n", cqe->res);
-				return 1;
-			}
-			continue;
-		}
 		if (cqe->res != 1) {
 			fprintf(stderr, "expected read %d\n", cqe->res);
 			return 1;
@@ -580,7 +570,7 @@ static int test_buf_select(const char *filename, int nonvec)
 	for (i = 0; i < BUFFERS; i++)
 		memset(vecs[i].iov_base, 0x55, vecs[i].iov_len);
 
-	ret = provide_buffers_iovec(&ring, 1, -1);
+	ret = provide_buffers_iovec(&ring, 1);
 	if (ret)
 		return ret;
 
@@ -606,7 +596,7 @@ static int test_rem_buf(int batch, int sqe_flags)
 		return 1;
 	}
 
-	ret = provide_buffers_iovec(&ring, bgid, -1);
+	ret = provide_buffers_iovec(&ring, bgid);
 	if (ret)
 		return ret;
 

base-commit: f8eb5f804288e10ae7ef442ef482e4dd8b18fee7
-- 
2.30.2


             reply	other threads:[~2022-07-04 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 16:06 Dylan Yudaken [this message]
2022-07-05 14:38 ` [PATCH liburing] fix test_buf_select_pipe on older kernels 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 \
    [email protected] \
    [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