From: Park Tae-sun <ts930@dgu.ac.kr>
To: Andrew Morton <akpm@linux-foundation.org>, Shuah Khan <shuah@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Park Tae-sun <ts930@dgu.ac.kr>
Subject: [PATCH] selftests/mm: mremap_test: handle ENOSYS for userfaultfd and add missing newlines
Date: Tue, 22 Sep 2026 15:51:43 +0900 [thread overview]
Message-ID: <20260922065143.118702-1-ts930@dgu.ac.kr> (raw)
When running mremap_test on a kernel built without CONFIG_USERFAULTFD,
test 26 fails:
userfaultfd: Function not implemented
not ok 26 mremap move multiple invalid vmas
This happens because mremap_move_multi_invalid_vmas() only checks for
EPERM, so ENOSYS is treated as an unexpected failure instead of being
skipped.
In addition, ksft_test_result_skip() in both
mremap_move_multi_invalid_vmas() and its fallback stub is missing a
trailing newline, which causes the subsequent TAP summary count to get
stuck on the same line:
ok 26 # SKIP ... - missing uffd# 1 skipped test(s) detected...
Fix this following the switch pattern in guard-regions.c (lines 1498-1506):
check for EPERM (advising running as root) and ENOSYS (missing uffd), move
perror() to default so expected skips don't print noise to stderr, and add
the missing '\n' to both skip strings.
Tested:
- On a minimal kernel without CONFIG_USERFAULTFD in QEMU:
ok 26 # SKIP mremap move multiple invalid vmas - missing uffd
# Totals: pass:22 fail:0 xfail:3 xpass:0 skip:1 error:0
- As an unprivileged user on host (vm.unprivileged_userfaultfd=0):
ok 26 # SKIP mremap move multiple invalid vmas -
no uffd permissions, try running as root
# 1 skipped test(s) detected.
- On a kernel with CONFIG_USERFAULTFD=y in QEMU:
ok 26 mremap move multiple invalid vmas
# Totals: pass:23 fail:0 xfail:3 xpass:0 skip:0 error:0
Signed-off-by: Park Tae-sun <ts930@dgu.ac.kr>
---
tools/testing/selftests/mm/mremap_test.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index 131d9d6db867..1fa2f6aa1a19 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -743,14 +743,19 @@ static void mremap_move_multi_invalid_vmas(FILE *maps_fp,
uffd = syscall(__NR_userfaultfd, O_NONBLOCK);
if (uffd == -1) {
- err = errno;
- perror("userfaultfd");
- if (err == EPERM) {
- ksft_test_result_skip("%s - missing uffd", test_name);
+ switch (errno) {
+ case EPERM:
+ ksft_test_result_skip("%s - no uffd permissions, try running as root\n",
+ test_name);
return;
+ case ENOSYS:
+ ksft_test_result_skip("%s - missing uffd\n", test_name);
+ return;
+ default:
+ perror("userfaultfd");
+ success = false;
+ goto out;
}
- success = false;
- goto out;
}
if (ioctl(uffd, UFFDIO_API, &api)) {
perror("ioctl UFFDIO_API");
@@ -965,7 +970,7 @@ static void mremap_move_multi_invalid_vmas(FILE *maps_fp, unsigned long page_siz
{
char *test_name = "mremap move multiple invalid vmas";
- ksft_test_result_skip("%s - missing uffd", test_name);
+ ksft_test_result_skip("%s - missing uffd\n", test_name);
}
#endif /* __NR_userfaultfd */
--
2.43.0
next reply other threads:[~2026-09-22 6:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 6:51 Park Tae-sun [this message]
2026-09-22 7:09 ` [PATCH] selftests/mm: mremap_test: handle ENOSYS for userfaultfd and add missing newlines Sarthak Sharma
2026-09-22 7:19 ` Park Tae-sun
2026-09-22 8:06 ` Lorenzo Stoakes (ARM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922065143.118702-1-ts930@dgu.ac.kr \
--to=ts930@dgu.ac.kr \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox