* [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable huge pages
@ 2025-02-26 20:36 Pavel Begunkov
2025-02-26 23:40 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2025-02-26 20:36 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable huge pages
2025-02-26 20:36 [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable huge pages Pavel Begunkov
@ 2025-02-26 23:40 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-02-26 23:40 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
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,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-26 23:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 20:36 [PATCH liburing 1/1] tests/send-zerocopy: add flag to disable huge pages Pavel Begunkov
2025-02-26 23:40 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox