public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@meta.com>
To: <io-uring@vger.kernel.org>, <axboe@kernel.dk>, <csander@purestorage.com>
Cc: Keith Busch <kbusch@kernel.org>
Subject: [PATCHv6 6/6] test/fdinfo: add mixed sqe option to fdinfo test
Date: Wed, 22 Oct 2025 10:19:24 -0700	[thread overview]
Message-ID: <20251022171924.2326863-7-kbusch@meta.com> (raw)
In-Reply-To: <20251022171924.2326863-1-kbusch@meta.com>

From: Keith Busch <kbusch@kernel.org>

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 test/fdinfo.c | 50 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/test/fdinfo.c b/test/fdinfo.c
index 49522a0a..422e4e6d 100644
--- a/test/fdinfo.c
+++ b/test/fdinfo.c
@@ -57,7 +57,7 @@ static void fdinfo_read(struct io_uring *ring)
 
 static int __test_io(const char *file, struct io_uring *ring, int write,
 		     int buffered, int sqthread, int fixed, int nonvec,
-		     int buf_select, int seq, int exp_len)
+		     int buf_select, int seq, int exp_len, int mixed)
 {
 	struct io_uring_sqe *sqe;
 	struct io_uring_cqe *cqe;
@@ -66,9 +66,9 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
 	off_t offset;
 
 #ifdef VERBOSE
-	fprintf(stdout, "%s: start %d/%d/%d/%d/%d: ", __FUNCTION__, write,
+	fprintf(stdout, "%s: start %d/%d/%d/%d/%d/%d: ", __FUNCTION__, write,
 							buffered, sqthread,
-							fixed, nonvec);
+							fixed, nonvec, mixed);
 #endif
 	if (write)
 		open_flags = O_WRONLY;
@@ -107,6 +107,17 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
 
 	offset = 0;
 	for (i = 0; i < BUFFERS; i++) {
+		if (mixed && i & 1) {
+			sqe = io_uring_get_sqe128(ring);
+			if (!sqe) {
+				fprintf(stderr, "sqe get failed\n");
+				goto err;
+			}
+			io_uring_prep_nop128(sqe);
+			sqe->user_data = i;
+			continue;
+		}
+
 		sqe = io_uring_get_sqe(ring);
 		if (!sqe) {
 			fprintf(stderr, "sqe get failed\n");
@@ -171,9 +182,13 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
 	fdinfo_read(ring);
 
 	ret = io_uring_submit(ring);
-	if (ret != BUFFERS) {
+	if (!mixed && ret != BUFFERS) {
 		fprintf(stderr, "submit got %d, wanted %d\n", ret, BUFFERS);
 		goto err;
+	} else if (mixed && ret != BUFFERS + (BUFFERS >> 1)) {
+		fprintf(stderr, "submit got %d, wanted %d\n", ret,
+			BUFFERS + (BUFFERS >> 1));
+		goto err;
 	}
 
 	for (i = 0; i < 10; i++) {
@@ -187,7 +202,13 @@ static int __test_io(const char *file, struct io_uring *ring, int write,
 			fprintf(stderr, "wait_cqe=%d\n", ret);
 			goto err;
 		}
-		if (cqe->res == -EINVAL && nonvec) {
+		if (mixed && cqe->user_data & 1) {
+			if (cqe->user_data > 32) {
+				fprintf(stderr, "cqe user data %lld, max expected %d\n",
+					cqe->user_data, BUFFERS - 1);
+				goto err;
+			}
+		} else if (cqe->res == -EINVAL && nonvec) {
 			if (!warned) {
 				fprintf(stdout, "Non-vectored IO not "
 					"supported, skipping\n");
@@ -253,15 +274,19 @@ err:
 	return 1;
 }
 static int test_io(const char *file, int write, int buffered, int sqthread,
-		   int fixed, int nonvec, int exp_len)
+		   int fixed, int nonvec, int exp_len, int mixed)
 {
 	struct io_uring ring;
-	int ret, ring_flags = 0;
+	int ret, ring_flags = 0, entries = 64;
 
 	if (sqthread)
 		ring_flags = IORING_SETUP_SQPOLL;
+	if (mixed) {
+		ring_flags |= IORING_SETUP_SQE_MIXED;
+		entries = 128;
+	}
 
-	ret = t_create_ring(64, &ring, ring_flags);
+	ret = t_create_ring(entries, &ring, ring_flags);
 	if (ret == T_SETUP_SKIP)
 		return 0;
 	if (ret != T_SETUP_OK) {
@@ -270,7 +295,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread,
 	}
 
 	ret = __test_io(file, &ring, write, buffered, sqthread, fixed, nonvec,
-			0, 0, exp_len);
+			0, 0, exp_len, mixed);
 	io_uring_queue_exit(&ring);
 	return ret;
 }
@@ -380,17 +405,18 @@ int main(int argc, char *argv[])
 	vecs = t_create_buffers(BUFFERS, BS);
 
 	/* if we don't have nonvec read, skip testing that */
-	nr = has_nonvec_read() ? 32 : 16;
+	nr = has_nonvec_read() ? 64 : 32;
 
 	for (i = 0; i < nr; i++) {
 		int write = (i & 1) != 0;
 		int buffered = (i & 2) != 0;
 		int sqthread = (i & 4) != 0;
 		int fixed = (i & 8) != 0;
-		int nonvec = (i & 16) != 0;
+		int mixed = (i & 16) != 0;
+		int nonvec = (i & 32) != 0;
 
 		ret = test_io(fname, write, buffered, sqthread, fixed, nonvec,
-			      BS);
+			      BS, mixed);
 		if (ret == T_EXIT_SKIP)
 			continue;
 		if (ret) {
-- 
2.47.3


  parent reply	other threads:[~2025-10-22 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 17:19 [PATCHv6 0/6] liburing: support for mixed sqes Keith Busch
2025-10-22 17:19 ` [PATCHv6 1/6] liburing: provide uring_cmd prep function Keith Busch
2025-10-22 17:19 ` [PATCHv6 2/6] Add support IORING_SETUP_SQE_MIXED Keith Busch
2025-10-22 17:35   ` Jens Axboe
2025-10-22 17:19 ` [PATCHv6 3/6] test: add nop testing for IORING_SETUP_SQE_MIXED Keith Busch
2025-10-22 17:19 ` [PATCHv6 4/6] test: add mixed sqe test for uring commands Keith Busch
2025-10-22 17:19 ` [PATCHv6 5/6] test/fdinfo: flush sq prior to reading Keith Busch
2025-10-22 17:19 ` Keith Busch [this message]
2025-10-22 17:40 ` [PATCHv6 0/6] liburing: support for mixed sqes 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=20251022171924.2326863-7-kbusch@meta.com \
    --to=kbusch@meta.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kbusch@kernel.org \
    /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