From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing v2 3/3] io_uring/sendzc: add DEFER_TASKRUN testing
Date: Mon, 8 Apr 2024 17:38:12 +0100 [thread overview]
Message-ID: <a0d822f0e8ebb5e78856457c126dea25b9a517b9.1712594147.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/send-zerocopy.c | 167 +++++++++++++++++++++++++++----------------
1 file changed, 107 insertions(+), 60 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index bfb15d2..ad214bb 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -769,12 +769,69 @@ static int test_invalid_zc(int fds[2])
return 0;
}
-int main(int argc, char *argv[])
+static int run_basic_tests(void)
{
struct sockaddr_storage addr;
- struct io_uring ring;
- int i, ret, sp[2];
+ int ret, i, sp[2];
+
+ /* create TCP IPv6 pair */
+ ret = create_socketpair_ip(&addr, &sp[0], &sp[1], true, true, false, true);
+ if (ret) {
+ fprintf(stderr, "sock prep failed %d\n", ret);
+ return -1;
+ }
+
+ for (i = 0; i < 2; i++) {
+ struct io_uring ring;
+ unsigned ring_flags = 0;
+
+ if (i & 1)
+ ring_flags |= IORING_SETUP_DEFER_TASKRUN;
+
+ ret = io_uring_queue_init(32, &ring, ring_flags);
+ if (ret) {
+ if (ret == -EINVAL)
+ continue;
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ return -1;
+ }
+
+ ret = test_basic_send(&ring, sp[0], sp[1]);
+ if (ret) {
+ fprintf(stderr, "test_basic_send() failed\n");
+ return -1;
+ }
+
+ ret = test_send_faults(sp[0], sp[1]);
+ if (ret) {
+ fprintf(stderr, "test_send_faults() failed\n");
+ return -1;
+ }
+
+ ret = test_invalid_zc(sp);
+ if (ret) {
+ fprintf(stderr, "test_invalid_zc() failed\n");
+ return -1;
+ }
+
+ ret = test_async_addr(&ring);
+ if (ret) {
+ fprintf(stderr, "test_async_addr() failed\n");
+ return T_EXIT_FAIL;
+ }
+
+ io_uring_queue_exit(&ring);
+ }
+
+ close(sp[0]);
+ close(sp[1]);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
size_t len;
+ int ret, i;
if (argc > 1)
return T_EXIT_SKIP;
@@ -791,13 +848,6 @@ int main(int argc, char *argv[])
page_sz = sysconf(_SC_PAGESIZE);
- /* create TCP IPv6 pair */
- ret = create_socketpair_ip(&addr, &sp[0], &sp[1], true, true, false, true);
- if (ret) {
- fprintf(stderr, "sock prep failed %d\n", ret);
- return T_EXIT_FAIL;
- }
-
len = LARGE_BUF_SIZE;
tx_buffer = aligned_alloc(page_sz, len);
rx_buffer = aligned_alloc(page_sz, len);
@@ -847,65 +897,62 @@ int main(int argc, char *argv[])
}
}
- ret = io_uring_queue_init(32, &ring, 0);
- if (ret) {
- fprintf(stderr, "queue init failed: %d\n", ret);
+ ret = run_basic_tests();
+ if (ret)
return T_EXIT_FAIL;
- }
- ret = test_basic_send(&ring, sp[0], sp[1]);
- if (ret) {
- fprintf(stderr, "test_basic_send() failed\n");
- return T_EXIT_FAIL;
- }
+ for (i = 0; i < 2; i++) {
+ struct io_uring ring;
+ unsigned ring_flags = 0;
- ret = test_send_faults(sp[0], sp[1]);
- if (ret) {
- fprintf(stderr, "test_send_faults() failed\n");
- return T_EXIT_FAIL;
- }
+ if (i & 1)
+ ring_flags |= IORING_SETUP_SINGLE_ISSUER |
+ IORING_SETUP_DEFER_TASKRUN;
- ret = test_invalid_zc(sp);
- if (ret) {
- fprintf(stderr, "test_invalid_zc() failed\n");
- return T_EXIT_FAIL;
- }
+ ret = io_uring_queue_init(32, &ring, ring_flags);
+ if (ret) {
+ if (ret == -EINVAL)
+ continue;
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ return -1;
+ }
- close(sp[0]);
- close(sp[1]);
+ ret = t_register_buffers(&ring, buffers_iov, ARRAY_SIZE(buffers_iov));
+ if (ret == T_SETUP_SKIP) {
+ fprintf(stderr, "can't register bufs, skip\n");
+ goto out;
+ } else if (ret != T_SETUP_OK) {
+ fprintf(stderr, "buffer registration failed %i\n", ret);
+ return T_EXIT_FAIL;
+ }
- ret = test_async_addr(&ring);
- if (ret) {
- fprintf(stderr, "test_async_addr() failed\n");
- return T_EXIT_FAIL;
- }
+ if (buffers_iov[BUF_T_HUGETLB].iov_base) {
+ buffers_iov[BUF_T_HUGETLB].iov_base += 13;
+ buffers_iov[BUF_T_HUGETLB].iov_len -= 26;
+ }
+ if (buffers_iov[BUF_T_LARGE].iov_base) {
+ buffers_iov[BUF_T_LARGE].iov_base += 13;
+ buffers_iov[BUF_T_LARGE].iov_len -= 26;
+ }
- ret = t_register_buffers(&ring, buffers_iov, ARRAY_SIZE(buffers_iov));
- if (ret == T_SETUP_SKIP) {
- fprintf(stderr, "can't register bufs, skip\n");
- goto out;
- } else if (ret != T_SETUP_OK) {
- fprintf(stderr, "buffer registration failed %i\n", ret);
- return T_EXIT_FAIL;
- }
+ ret = test_inet_send(&ring);
+ if (ret) {
+ fprintf(stderr, "test_inet_send() failed (defer_taskrun %i)\n",
+ ring_flags & IORING_SETUP_DEFER_TASKRUN);
+ return T_EXIT_FAIL;
+ }
- if (buffers_iov[BUF_T_HUGETLB].iov_base) {
- buffers_iov[BUF_T_HUGETLB].iov_base += 13;
- buffers_iov[BUF_T_HUGETLB].iov_len -= 26;
- }
- if (buffers_iov[BUF_T_LARGE].iov_base) {
- buffers_iov[BUF_T_LARGE].iov_base += 13;
- buffers_iov[BUF_T_LARGE].iov_len -= 26;
+ if (buffers_iov[BUF_T_HUGETLB].iov_base) {
+ buffers_iov[BUF_T_HUGETLB].iov_base -= 13;
+ buffers_iov[BUF_T_HUGETLB].iov_len += 26;
+ }
+ if (buffers_iov[BUF_T_LARGE].iov_base) {
+ buffers_iov[BUF_T_LARGE].iov_base -= 13;
+ buffers_iov[BUF_T_LARGE].iov_len += 26;
+ }
+out:
+ io_uring_queue_exit(&ring);
}
- ret = test_inet_send(&ring);
- if (ret) {
- fprintf(stderr, "test_inet_send() failed\n");
- return T_EXIT_FAIL;
- }
-out:
- io_uring_queue_exit(&ring);
- close(sp[0]);
- close(sp[1]);
return T_EXIT_PASS;
}
--
2.44.0
next prev parent reply other threads:[~2024-04-08 16:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 16:38 [PATCH liburing v2 0/3] improve sendzc tests Pavel Begunkov
2024-04-08 16:38 ` [PATCH liburing v2 1/3] test: handle test_send_faults()'s cases one by one Pavel Begunkov
2024-04-08 16:38 ` [PATCH liburing v2 2/3] test/sendzc: improve zc support probing Pavel Begunkov
2024-04-08 16:38 ` Pavel Begunkov [this message]
2024-04-09 3:45 ` [PATCH liburing v2 0/3] improve sendzc tests 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=a0d822f0e8ebb5e78856457c126dea25b9a517b9.1712594147.git.asml.silence@gmail.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