linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests/mm: skip uffd tests in madv_guard if uffd is not present.
@ 2025-05-15 18:23 Zi Yan
  2025-05-15 18:23 ` [PATCH 2/2] selftests/mm: skip hugevm test if kernel config file " Zi Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Zi Yan @ 2025-05-15 18:23 UTC (permalink / raw)
  To: Pedro Falcato, Lorenzo Stoakes, Adam Sindelar, linux-mm
  Cc: Andrew Morton, linux-kselftest, linux-kernel, Zi Yan

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

Signed-off-by: Zi Yan <ziy@nvidia.com>
---
 tools/testing/selftests/mm/guard-regions.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
index 0cd9d236649d..93af3d3760f9 100644
--- a/tools/testing/selftests/mm/guard-regions.c
+++ b/tools/testing/selftests/mm/guard-regions.c
@@ -1453,8 +1453,21 @@ TEST_F(guard_regions, uffd)
 
 	/* Set up uffd. */
 	uffd = userfaultfd(0);
-	if (uffd == -1 && errno == EPERM)
-		ksft_exit_skip("No userfaultfd permissions, try running as root.\n");
+	if (uffd == -1) {
+		switch (errno) {
+		case EPERM:
+			SKIP(return, "No userfaultfd permissions, try running as root.");
+			break;
+		case ENOSYS:
+			SKIP(return, "userfaultfd is not supported/not enabled.");
+			break;
+		default:
+			ksft_exit_fail_msg("userfaultfd failed with %s\n",
+					   strerror(errno));
+			break;
+		}
+	}
+
 	ASSERT_NE(uffd, -1);
 
 	ASSERT_EQ(ioctl(uffd, UFFDIO_API, &api), 0);
-- 
2.47.2



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-05-15 19:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-15 18:23 [PATCH 1/2] selftests/mm: skip uffd tests in madv_guard if uffd is not present Zi Yan
2025-05-15 18:23 ` [PATCH 2/2] selftests/mm: skip hugevm test if kernel config file " Zi Yan
2025-05-15 18:43   ` Lorenzo Stoakes
2025-05-15 19:15     ` Pedro Falcato
2025-05-15 18:41 ` [PATCH 1/2] selftests/mm: skip uffd tests in madv_guard if uffd " Lorenzo Stoakes
2025-05-15 18:46   ` Zi Yan
2025-05-15 18:49     ` Lorenzo Stoakes
2025-05-15 18:53       ` Zi Yan
2025-05-15 19:11 ` Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox