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 guard_regions.uffd tests when uffd is not present

Patch series "Skip mm selftests instead when kernel features are not
present", v2.

Two guard_regions tests on userfaultfd fail when userfaultfd is not
present. Skip them instead.

hugevm test reads kernel config to get page table level information and
fails when neither /proc/config.gz nor /boot/config-* is present. Skip it
instead.


This patch (of 2):

When userfaultfd is not compiled into kernel, userfaultfd() returns -1,
causing guard_regions.uffd tests to fail. Skip the tests instead.

Link: https://lkml.kernel.org/r/20250516132938.356627-1-ziy@nvidia.com
Link: https://lkml.kernel.org/r/20250516132938.356627-2-ziy@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Cc: Adam Sindelar <adam@wowsignal.io>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Zi Yan and committed by
Andrew Morton
6d211303 c5a9deac

+15 -2
+15 -2
tools/testing/selftests/mm/guard-regions.c
··· 1453 1453 1454 1454 /* Set up uffd. */ 1455 1455 uffd = userfaultfd(0); 1456 - if (uffd == -1 && errno == EPERM) 1457 - ksft_exit_skip("No userfaultfd permissions, try running as root.\n"); 1456 + if (uffd == -1) { 1457 + switch (errno) { 1458 + case EPERM: 1459 + SKIP(return, "No userfaultfd permissions, try running as root."); 1460 + break; 1461 + case ENOSYS: 1462 + SKIP(return, "userfaultfd is not supported/not enabled."); 1463 + break; 1464 + default: 1465 + ksft_exit_fail_msg("userfaultfd failed with %s\n", 1466 + strerror(errno)); 1467 + break; 1468 + } 1469 + } 1470 + 1458 1471 ASSERT_NE(uffd, -1); 1459 1472 1460 1473 ASSERT_EQ(ioctl(uffd, UFFDIO_API, &api), 0);