From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Ricardo Branco" <rbranco@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] userfaultfd: Add test using UFFDIO_CONTINUE
Date: Mon, 30 Mar 2026 08:31:56 +0000 [thread overview]
Message-ID: <69ca34fd.050a0220.3c7430.fd79@mx.google.com> (raw)
In-Reply-To: <20260321195817.119695-1-rbranco@suse.de>
Hi Ricardo,
The commit message needs a body explaining why this test is being added
(e.g. UFFDIO_CONTINUE with minor shmem faults was previously untested)
and that the missing UFFD_PAGEFAULT_FLAG_MINOR fallback define is also
added.
> +#define _GNU_SOURCE
> +#include "config.h"
_GNU_SOURCE is not needed here. None of the other userfaultfd tests use
it and nothing in this test requires GNU extensions.
[...]
> +static int page_size;
> +static char *page;
> +static int uffd;
> +static int memfd = -1;
uffd must be initialized to -1. Zero is a valid fd (stdin).
[...]
> +static void reset_pages(void)
> +{
> + if (page) {
> + SAFE_MUNMAP(page, page_size);
> + page = NULL;
> + }
> +
> + if (memfd >= 0) {
Use `if (memfd != -1)` -- that is the LTP fd-check convention.
Also, reset_pages() is the .cleanup callback but never closes uffd. If
run() aborts after SAFE_USERFAULTFD() but before spawning the thread
(e.g. TCONF at the feature check), uffd leaks. Add:
if (uffd != -1)
SAFE_CLOSE(uffd);
[...]
> + SAFE_IOCTL(uffd, UFFDIO_CONTINUE, &uffdio_continue);
> +
> + close(uffd);
> + return NULL;
Use SAFE_CLOSE(uffd) instead of close(uffd).
[...]
> + uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
Consider passing true for the retry parameter. The test does not need
privileged userfaultfd -- UFFD_FEATURE_MINOR_SHMEM works fine with
UFFD_USER_MODE_ONLY. With false, the test unnecessarily TCONFs on
systems where unprivileged_userfaultfd is disabled.
[...]
> + uffdio_continue.range.start =
> + msg.arg.pagefault.address & ~(page_size - 1);
page_size is int, so ~(page_size - 1) produces a signed int mask that
gets sign-extended when applied to the __u64 address. Cast to avoid
relying on implementation-defined behavior:
msg.arg.pagefault.address & ~((unsigned long)page_size - 1);
[...]
> + .needs_kconfigs = (const char *[]) {
> + "CONFIG_HAVE_ARCH_USERFAULTFD_WP=y",
> + NULL
> + },
This test uses UFFD_FEATURE_MINOR_SHMEM, not write-protect.
CONFIG_HAVE_ARCH_USERFAULTFD_WP will wrongly skip the test on
architectures that support minor faults but not WP. Use
CONFIG_USERFAULTFD=y instead. The version gate is already handled by
.min_kver = "5.14".
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-30 8:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 19:58 [LTP] [PATCH] userfaultfd: Add test using UFFDIO_CONTINUE Ricardo Branco
2026-03-30 8:31 ` Andrea Cervesato via ltp [this message]
2026-03-30 9:24 ` Ricardo Branco
2026-03-30 9:39 ` Andrea Cervesato via ltp
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=69ca34fd.050a0220.3c7430.fd79@mx.google.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
--cc=rbranco@suse.de \
/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