Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm: skip hugepage-mremap test if userfaultfd unavailable

Gracefully skip test if userfaultfd is not supported (ENOSYS) or not
permitted (EPERM), instead of failing. This avoids misleading failures
with clear skip messages.

--------------
Before Patch
--------------
~ running ./hugepage-mremap
...
~ Bail out! userfaultfd: Function not implemented
~ Planned tests != run tests (1 != 0)
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
~ [FAIL]
not ok 4 hugepage-mremap # exit=1

--------------
After Patch
--------------
~ running ./hugepage-mremap
...
~ ok 2 # SKIP userfaultfd is not supported/not enabled.
~ 1 skipped test(s) detected.
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
~ [SKIP]
ok 4 hugepage-mremap # SKIP

Link: https://lkml.kernel.org/r/20250816040113.760010-8-aboorvad@linux.ibm.com
Co-developed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mariano Pache <npache@redhat.com>
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Aboorva Devarajan and committed by
Andrew Morton
19de1e5d e3621543

+13 -3
+13 -3
tools/testing/selftests/mm/hugepage-mremap.c
··· 65 65 struct uffdio_api uffdio_api; 66 66 67 67 /* Create and enable userfaultfd object. */ 68 - 69 68 uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK); 70 - if (uffd == -1) 71 - ksft_exit_fail_msg("userfaultfd: %s\n", strerror(errno)); 69 + if (uffd == -1) { 70 + switch (errno) { 71 + case EPERM: 72 + ksft_exit_skip("Insufficient permissions, try running as root.\n"); 73 + break; 74 + case ENOSYS: 75 + ksft_exit_skip("userfaultfd is not supported/not enabled.\n"); 76 + break; 77 + default: 78 + ksft_exit_fail_msg("userfaultfd failed with %s\n", strerror(errno)); 79 + break; 80 + } 81 + } 72 82 73 83 uffdio_api.api = UFFD_API; 74 84 uffdio_api.features = 0;