public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable huge pages
Date: Wed, 26 Feb 2025 20:36:15 +0000	[thread overview]
Message-ID: <5748afaecdf24e8ca1f1c9d407e809e8a485fe16.1740601594.git.asml.silence@gmail.com> (raw)

Huge page test is too heavy for low powered setups, so add a convenient
way to disable them.

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

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 7135f57c..c8eafe28 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -72,6 +72,7 @@ static struct iovec buffers_iov[__BUF_NR];
 static bool has_sendzc;
 static bool has_sendmsg;
 static bool hit_enomem;
+static bool try_hugepages = 1;
 
 static int probe_zc_support(void)
 {
@@ -900,6 +901,15 @@ static int run_basic_tests(void)
 	return 0;
 }
 
+static void free_buffers(void)
+{
+	if (tx_buffer)
+		free(tx_buffer);
+	if (rx_buffer)
+		free(rx_buffer);
+	tx_buffer = rx_buffer = NULL;
+}
+
 int main(int argc, char *argv[])
 {
 	size_t len;
@@ -920,27 +930,29 @@ int main(int argc, char *argv[])
 
 	page_sz = sysconf(_SC_PAGESIZE);
 
-	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);
+	if (try_hugepages) {
+		len = LARGE_BUF_SIZE;
+		tx_buffer = aligned_alloc(page_sz, len);
+		rx_buffer = aligned_alloc(page_sz, len);
 
-		printf("skip large buffer tests, can't alloc\n");
+		if (tx_buffer && rx_buffer) {
+			buffers_iov[BUF_T_LARGE].iov_base = tx_buffer;
+			buffers_iov[BUF_T_LARGE].iov_len = len;
+		} else {
+			printf("skip large buffer tests, can't alloc\n");
+			free_buffers();
+		}
+	}
 
+	if (!tx_buffer) {
 		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;
+
+		if (!tx_buffer || !rx_buffer) {
+			fprintf(stderr, "can't allocate buffers\n");
+			return T_EXIT_FAIL;
+		}
 	}
 
 	srand((unsigned)time(NULL));
-- 
2.48.1


             reply	other threads:[~2025-02-26 20:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 20:36 Pavel Begunkov [this message]
2025-02-26 23:40 ` [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable 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=5748afaecdf24e8ca1f1c9d407e809e8a485fe16.1740601594.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