public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing 0/3] some extra zc tests
@ 2022-11-04 11:05 Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Pavel Begunkov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-04 11:05 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Pavel Begunkov (3):
  tests/zc: create a new ring for test_send_faults()
  tests/zc: add control flags tests
  tests/zc: extra verification for notif completions

 test/send-zerocopy.c | 55 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 13 deletions(-)

-- 
2.38.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults()
  2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
@ 2022-11-04 11:05 ` Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 2/3] tests/zc: add control flags tests Pavel Begunkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-04 11:05 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

We need IORING_SETUP_SUBMIT_ALL for test_send_faults() to be sure
io_uring doesn't stop submission on first failure.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/send-zerocopy.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index a50b5b1..30b50e1 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -116,7 +116,7 @@ static int test_basic_send(struct io_uring *ring, int sock_tx, int sock_rx)
 	return T_EXIT_PASS;
 }
 
-static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx)
+static int test_send_faults(int sock_tx, int sock_rx)
 {
 	struct io_uring_sqe *sqe;
 	struct io_uring_cqe *cqe;
@@ -124,24 +124,31 @@ static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx)
 	unsigned zc_flags = 0;
 	int payload_size = 100;
 	int ret, i, nr_cqes = 2;
+	struct io_uring ring;
 
-	sqe = io_uring_get_sqe(ring);
+	ret = io_uring_queue_init(32, &ring, IORING_SETUP_SUBMIT_ALL);
+	if (ret) {
+		fprintf(stderr, "queue init failed: %d\n", ret);
+		return -1;
+	}
+
+	sqe = io_uring_get_sqe(&ring);
 	io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size,
 			      msg_flags, zc_flags);
 	sqe->user_data = 1;
 
-	sqe = io_uring_get_sqe(ring);
+	sqe = io_uring_get_sqe(&ring);
 	io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
 			      msg_flags, zc_flags);
 	sqe->user_data = 2;
 	io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL,
 				    sizeof(struct sockaddr_in6));
 
-	ret = io_uring_submit(ring);
+	ret = io_uring_submit(&ring);
 	assert(ret == 2);
 
 	for (i = 0; i < nr_cqes; i++) {
-		ret = io_uring_wait_cqe(ring, &cqe);
+		ret = io_uring_wait_cqe(&ring, &cqe);
 		assert(!ret);
 		assert(cqe->user_data <= 2);
 
@@ -150,9 +157,9 @@ static int test_send_faults(struct io_uring *ring, int sock_tx, int sock_rx)
 			if (cqe->flags & IORING_CQE_F_MORE)
 				nr_cqes++;
 		}
-		io_uring_cqe_seen(ring, cqe);
+		io_uring_cqe_seen(&ring, cqe);
 	}
-	assert(check_cq_empty(ring));
+	assert(check_cq_empty(&ring));
 	return T_EXIT_PASS;
 }
 
@@ -728,7 +735,7 @@ int main(int argc, char *argv[])
 
 	has_sendmsg = io_check_zc_sendmsg(&ring);
 
-	ret = test_send_faults(&ring, sp[0], sp[1]);
+	ret = test_send_faults(sp[0], sp[1]);
 	if (ret) {
 		fprintf(stderr, "test_send_faults() failed\n");
 		return T_EXIT_FAIL;
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH liburing 2/3] tests/zc: add control flags tests
  2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Pavel Begunkov
@ 2022-11-04 11:05 ` Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 3/3] tests/zc: extra verification for notif completions Pavel Begunkov
  2022-11-05 15:20 ` [PATCH liburing 0/3] some extra zc tests Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-04 11:05 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/send-zerocopy.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 30b50e1..6e637f4 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -123,7 +123,7 @@ static int test_send_faults(int sock_tx, int sock_rx)
 	int msg_flags = 0;
 	unsigned zc_flags = 0;
 	int payload_size = 100;
-	int ret, i, nr_cqes = 2;
+	int ret, i, nr_cqes, nr_reqs = 3;
 	struct io_uring ring;
 
 	ret = io_uring_queue_init(32, &ring, IORING_SETUP_SUBMIT_ALL);
@@ -132,28 +132,44 @@ static int test_send_faults(int sock_tx, int sock_rx)
 		return -1;
 	}
 
+	/* invalid buffer */
 	sqe = io_uring_get_sqe(&ring);
 	io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size,
 			      msg_flags, zc_flags);
 	sqe->user_data = 1;
 
+	/* invalid address */
 	sqe = io_uring_get_sqe(&ring);
 	io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
 			      msg_flags, zc_flags);
-	sqe->user_data = 2;
 	io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL,
 				    sizeof(struct sockaddr_in6));
+	sqe->user_data = 2;
+
+	/* invalid send/recv flags */
+	sqe = io_uring_get_sqe(&ring);
+	io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
+			      msg_flags, ~0U);
+	sqe->user_data = 3;
 
 	ret = io_uring_submit(&ring);
-	assert(ret == 2);
+	assert(ret == nr_reqs);
 
+	nr_cqes = nr_reqs;
 	for (i = 0; i < nr_cqes; i++) {
 		ret = io_uring_wait_cqe(&ring, &cqe);
 		assert(!ret);
-		assert(cqe->user_data <= 2);
+		assert(cqe->user_data <= nr_reqs);
 
 		if (!(cqe->flags & IORING_CQE_F_NOTIF)) {
-			assert(cqe->res == -EFAULT);
+			int expected = (cqe->user_data == 3) ? -EINVAL : -EFAULT;
+
+			if (cqe->res != expected) {
+				fprintf(stderr, "invalid cqe res %i vs expected %i, "
+					"user_data %i\n",
+					cqe->res, expected, (int)cqe->user_data);
+				return -1;
+			}
 			if (cqe->flags & IORING_CQE_F_MORE)
 				nr_cqes++;
 		}
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH liburing 3/3] tests/zc: extra verification for notif completions
  2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Pavel Begunkov
  2022-11-04 11:05 ` [PATCH liburing 2/3] tests/zc: add control flags tests Pavel Begunkov
@ 2022-11-04 11:05 ` Pavel Begunkov
  2022-11-05 15:20 ` [PATCH liburing 0/3] some extra zc tests Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-04 11:05 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/send-zerocopy.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 6e637f4..16830df 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -172,6 +172,12 @@ static int test_send_faults(int sock_tx, int sock_rx)
 			}
 			if (cqe->flags & IORING_CQE_F_MORE)
 				nr_cqes++;
+		} else {
+			if (cqe->res != 0 || cqe->flags != IORING_CQE_F_NOTIF) {
+				fprintf(stderr, "invalid notif cqe %i %i\n",
+					cqe->res, cqe->flags);
+				return -1;
+			}
 		}
 		io_uring_cqe_seen(&ring, cqe);
 	}
-- 
2.38.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH liburing 0/3] some extra zc tests
  2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
                   ` (2 preceding siblings ...)
  2022-11-04 11:05 ` [PATCH liburing 3/3] tests/zc: extra verification for notif completions Pavel Begunkov
@ 2022-11-05 15:20 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-11-05 15:20 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On Fri, 4 Nov 2022 11:05:50 +0000, Pavel Begunkov wrote:
> Pavel Begunkov (3):
>   tests/zc: create a new ring for test_send_faults()
>   tests/zc: add control flags tests
>   tests/zc: extra verification for notif completions
> 
> test/send-zerocopy.c | 55 +++++++++++++++++++++++++++++++++-----------
>  1 file changed, 42 insertions(+), 13 deletions(-)
> 
> [...]

Applied, thanks!

[1/3] tests/zc: create a new ring for test_send_faults()
      commit: 799d6e0ed8103ac296135e8670c25cbd5c074a73
[2/3] tests/zc: add control flags tests
      commit: 81ab5f3831fe8dccb3e51b3be093791ef8ad2df8
[3/3] tests/zc: extra verification for notif completions
      commit: 3e3f71a6eb8356c129706cb88d150fe4e01fa19e

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-05 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
2022-11-04 11:05 ` [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Pavel Begunkov
2022-11-04 11:05 ` [PATCH liburing 2/3] tests/zc: add control flags tests Pavel Begunkov
2022-11-04 11:05 ` [PATCH liburing 3/3] tests/zc: extra verification for notif completions Pavel Begunkov
2022-11-05 15:20 ` [PATCH liburing 0/3] some extra zc tests Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox