diff mbox series

[liburing,1/1] tests/send-zerocopy: add flag to disable huge pages

Message ID 5748afaecdf24e8ca1f1c9d407e809e8a485fe16.1740601594.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series [liburing,1/1] tests/send-zerocopy: add flag to disable huge pages | expand

Commit Message

Pavel Begunkov Feb. 26, 2025, 8:36 p.m. UTC
Huge page test is too heavy for low powered setups, so add a convenient
way to disable them.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/send-zerocopy.c | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

Comments

Jens Axboe Feb. 26, 2025, 11:40 p.m. UTC | #1
On Wed, 26 Feb 2025 20:36:15 +0000, Pavel Begunkov wrote:
> Huge page test is too heavy for low powered setups, so add a convenient
> way to disable them.
> 
> 

Applied, thanks!

[1/1] tests/send-zerocopy: add flag to disable huge pages
      commit: d507f1da3fae04ffdd61ba939cf2f024683e900c

Best regards,
diff mbox series

Patch

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));