From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/7] tests/send: don't use a constant for page size
Date: Tue, 21 Feb 2023 01:05:52 +0000 [thread overview]
Message-ID: <e5807646ba3ad5a315630fc3dbc363fa6c8c4e0a.1676941370.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/send-zerocopy.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 86a31cd..2e30e49 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -58,6 +58,10 @@ enum {
BUF_T_LARGE,
};
+/* 32MB, should be enough to trigger a short send */
+#define LARGE_BUF_SIZE (1U << 25)
+
+static size_t page_sz;
static char *tx_buffer, *rx_buffer;
static struct iovec buffers_iov[4];
static bool has_sendmsg;
@@ -706,6 +710,8 @@ int main(int argc, char *argv[])
if (argc > 1)
return T_EXIT_SKIP;
+ page_sz = sysconf(_SC_PAGESIZE);
+
/* create TCP IPv6 pair */
ret = create_socketpair_ip(&addr, &sp[0], &sp[1], true, true, false, true);
if (ret) {
@@ -713,30 +719,35 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}
- len = 1U << 25; /* 32MB, should be enough to trigger a short send */
- tx_buffer = aligned_alloc(4096, len);
- rx_buffer = aligned_alloc(4096, len);
+ len = LARGE_BUF_SIZE;
+ tx_buffer = aligned_alloc(page_sz, len);
+ rx_buffer = aligned_alloc(page_sz, len);
if (tx_buffer && rx_buffer) {
buffers_iov[BUF_T_LARGE].iov_base = tx_buffer;
buffers_iov[BUF_T_LARGE].iov_len = len;
} else {
+ if (tx_buffer)
+ free(tx_buffer);
+ if (rx_buffer)
+ free(rx_buffer);
+
printf("skip large buffer tests, can't alloc\n");
- len = 8192;
- tx_buffer = aligned_alloc(4096, len);
- rx_buffer = aligned_alloc(4096, len);
+ len = 2 * page_sz;
+ tx_buffer = aligned_alloc(page_sz, len);
+ rx_buffer = aligned_alloc(page_sz, len);
}
if (!tx_buffer || !rx_buffer) {
fprintf(stderr, "can't allocate buffers\n");
return T_EXIT_FAIL;
}
- buffers_iov[BUF_T_NORMAL].iov_base = tx_buffer + 4096;
- buffers_iov[BUF_T_NORMAL].iov_len = 4096;
+ 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;
buffers_iov[BUF_T_SMALL].iov_len = 137;
buffers_iov[BUF_T_NONALIGNED].iov_base = tx_buffer + BUFFER_OFFSET;
- buffers_iov[BUF_T_NONALIGNED].iov_len = 8192 - BUFFER_OFFSET - 13;
+ buffers_iov[BUF_T_NONALIGNED].iov_len = 2 * page_sz - BUFFER_OFFSET - 13;
ret = io_uring_queue_init(32, &ring, 0);
if (ret) {
--
2.39.1
next prev 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 ` Pavel Begunkov [this message]
2023-02-21 1:05 ` [PATCH liburing 2/7] send: improve buffer iteration Pavel Begunkov
2023-02-21 1:05 ` [PATCH liburing 3/7] send: test send with hugetlb Pavel Begunkov
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=e5807646ba3ad5a315630fc3dbc363fa6c8c4e0a.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