[Devel] [PATCH vz10] selftests: dma-buf: skip the huge page test without huge pages
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Tue Sep 1 03:41:24 MSK 2026
The last udmabuf test backs a memfd with MFD_HUGETLB. Where no huge
pages are reserved the mapping fails and the whole test is reported as
a failure.
https://virtuozzo.atlassian.net/browse/VSTOR-142448
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
.../selftests/drivers/dma-buf/udmabuf.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
index 6062723a172e..a3bb26c1991a 100644
--- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
+++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
@@ -25,6 +25,21 @@
static unsigned int page_size;
+static bool hugepages_available(void)
+{
+ unsigned long nr = 0;
+ FILE *f;
+
+ f = fopen("/proc/sys/vm/nr_hugepages", "r");
+ if (!f)
+ return false;
+ if (fscanf(f, "%lu", &nr) != 1)
+ nr = 0;
+ fclose(f);
+
+ return nr > 0;
+}
+
static int create_memfd_with_seals(off64_t size, bool hpage)
{
int memfd, ret;
@@ -234,6 +249,11 @@ int main(int argc, char *argv[])
close(memfd);
/* should work (migration of 2MB size huge pages)*/
+ if (!hugepages_available()) {
+ ksft_test_result_skip("%s: [SKIP,test-6] no huge pages\n", TEST_PREFIX);
+ close(devfd);
+ ksft_finished();
+ }
page_size = getpagesize() * 512; /* 2 MB */
size = MEMFD_SIZE * page_size;
memfd = create_memfd_with_seals(size, true);
--
2.55.0
More information about the Devel
mailing list