public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 3/7] send: test send with hugetlb
Date: Tue, 21 Feb 2023 01:05:54 +0000	[thread overview]
Message-ID: <c89fe57dea283ab376eb97a2dbc073c36720a880.1676941370.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index e663be7..f1277fa 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -33,6 +33,8 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/mman.h>
+#include <linux/mman.h>
 
 #include "liburing.h"
 #include "helpers.h"
@@ -56,6 +58,9 @@ enum {
 	BUF_T_SMALL,
 	BUF_T_NONALIGNED,
 	BUF_T_LARGE,
+	BUF_T_HUGETLB,
+
+	__BUF_NR,
 };
 
 /* 32MB, should be enough to trigger a short send */
@@ -63,7 +68,7 @@ enum {
 
 static size_t page_sz;
 static char *tx_buffer, *rx_buffer;
-static struct iovec buffers_iov[4];
+static struct iovec buffers_iov[__BUF_NR];
 static bool has_sendmsg;
 
 static bool check_cq_empty(struct io_uring *ring)
@@ -748,6 +753,11 @@ int main(int argc, char *argv[])
 		return T_EXIT_FAIL;
 	}
 
+	srand((unsigned)time(NULL));
+	for (i = 0; i < len; i++)
+		tx_buffer[i] = i;
+	memset(rx_buffer, 0, len);
+
 	buffers_iov[BUF_T_NORMAL].iov_base = tx_buffer + page_sz;
 	buffers_iov[BUF_T_NORMAL].iov_len = page_sz;
 	buffers_iov[BUF_T_SMALL].iov_base = tx_buffer;
@@ -755,17 +765,26 @@ int main(int argc, char *argv[])
 	buffers_iov[BUF_T_NONALIGNED].iov_base = tx_buffer + BUFFER_OFFSET;
 	buffers_iov[BUF_T_NONALIGNED].iov_len = 2 * page_sz - BUFFER_OFFSET - 13;
 
+	if (len == LARGE_BUF_SIZE) {
+		void *huge_page;
+		int off = page_sz + 27;
+
+		len = 1U << 22;
+		huge_page = mmap(NULL, len, PROT_READ|PROT_WRITE,
+				 MAP_PRIVATE | MAP_HUGETLB | MAP_HUGE_2MB | MAP_ANONYMOUS,
+				 -1, 0);
+		if (huge_page != MAP_FAILED) {
+			buffers_iov[BUF_T_HUGETLB].iov_base = huge_page + off;
+			buffers_iov[BUF_T_HUGETLB].iov_len = len - off;
+		}
+	}
+
 	ret = io_uring_queue_init(32, &ring, 0);
 	if (ret) {
 		fprintf(stderr, "queue init failed: %d\n", ret);
 		return T_EXIT_FAIL;
 	}
 
-	srand((unsigned)time(NULL));
-	for (i = 0; i < len; i++)
-		tx_buffer[i] = i;
-	memset(rx_buffer, 0, len);
-
 	ret = test_basic_send(&ring, sp[0], sp[1]);
 	if (ret == T_EXIT_SKIP)
 		return ret;
-- 
2.39.1


  parent reply	other threads:[~2023-02-21  1:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  1:05 [PATCH liburing 0/7] test sends with huge pages Pavel Begunkov
2023-02-21  1:05 ` [PATCH liburing 1/7] tests/send: don't use a constant for page size Pavel Begunkov
2023-02-21  1:05 ` [PATCH liburing 2/7] send: improve buffer iteration Pavel Begunkov
2023-02-21  1:05 ` Pavel Begunkov [this message]
2023-02-21  1:05 ` [PATCH liburing 4/7] examples/zc: add a hugetlb option Pavel Begunkov
2023-02-21  1:05 ` [PATCH liburing 5/7] test/send: don't use SO_ZEROCOPY if not available Pavel Begunkov
2023-02-21  1:05 ` [PATCH liburing 6/7] tests/send: improve error reporting Pavel Begunkov
2023-02-21  1:05 ` [PATCH liburing 7/7] tests/send: sends with offsets Pavel Begunkov
2023-02-22 16:54 ` [PATCH liburing 0/7] test sends with huge pages 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=c89fe57dea283ab376eb97a2dbc073c36720a880.1676941370.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