From: Cyril Hrubis <chrubis@suse.cz>
To: Ricardo Branco <rbranco@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v6 2/2] userfaultfd: Add new test using UFFDIO_CONTINUE
Date: Tue, 5 May 2026 16:12:41 +0200 [thread overview]
Message-ID: <afn62QQkJgwO28hE@yuki.lan> (raw)
In-Reply-To: <20260411094742.219667-2-rbranco@suse.de>
Hi!
> +static void *handle_thread(void *arg LTP_ATTRIBUTE_UNUSED)
> +{
> + static struct uffd_msg msg;
> + struct uffdio_continue uffdio_continue = {};
> + struct pollfd pollfd;
> + int nready;
> + char z = 'Z';
> +
> + pollfd.fd = uffd;
> + pollfd.events = POLLIN;
> + nready = poll(&pollfd, 1, -1);
> + if (nready == -1)
> + tst_brk(TBROK | TERRNO, "Error on poll");
> +
> + SAFE_READ(1, uffd, &msg, sizeof(msg));
> +
> + if (msg.event != UFFD_EVENT_PAGEFAULT)
> + tst_brk(TFAIL, "Received unexpected UFFD_EVENT %d", msg.event);
> +
> + if (!(msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_MINOR)) {
> + tst_brk(TBROK, "expected MINOR fault, got flags=0x%llx",
^
TFAIL
This is clearly a test assertion and thus a test failure.
> + (unsigned long long)msg.arg.pagefault.flags);
> + }
> +
> + /* Update the shmem page in page cache before resuming the fault. */
> + SAFE_PWRITE(1, memfd, &z, 1, 0);
> +
> + uffdio_continue.range.start =
> + msg.arg.pagefault.address & ~((unsigned long)page_size - 1);
> + uffdio_continue.range.len = page_size;
> +
> + SAFE_IOCTL(uffd, UFFDIO_CONTINUE, &uffdio_continue);
> +
> + SAFE_CLOSE(uffd);
> + return NULL;
> +}
> +
> +static void run(void)
> +{
> + pthread_t thr;
> + struct uffdio_api uffdio_api = {};
> + struct uffdio_register uffdio_register;
> +
> + set_pages();
> +
> + uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, true);
> + uffdio_api.api = UFFD_API;
> + uffdio_api.features = 0;
> + SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
> + if (!(uffdio_api.features & UFFD_FEATURE_MINOR_SHMEM))
> + tst_brk(TCONF, "UFFD_FEATURE_MINOR_SHMEM not supported");
> + SAFE_CLOSE(uffd);
> +
> + uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
> +
> + uffdio_api.api = UFFD_API;
> + uffdio_api.features = UFFD_FEATURE_MINOR_SHMEM;
> +
> + SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
> +
> + uffdio_register.range.start = (unsigned long) page;
> + uffdio_register.range.len = page_size;
> + uffdio_register.mode = UFFDIO_REGISTER_MODE_MINOR;
> +
> + SAFE_IOCTL(uffd, UFFDIO_REGISTER, &uffdio_register);
> +
> + /*
> + * Drop PTEs while retaining the cached shmem page so the next access
> + * faults in MINOR mode.
> + */
> + if (madvise(page, page_size, MADV_DONTNEED) < 0)
> + tst_brk(TBROK | TERRNO, "madvise MADV_DONTNEED failed");
> +
> + SAFE_PTHREAD_CREATE(&thr, NULL, (void *) handle_thread, NULL);
> +
> + char c = page[0];
> +
> + if (c == 'Z')
> + tst_res(TPASS, "Pagefault handled via UFFDIO_CONTINUE");
> + else
> + tst_res(TFAIL, "pagefault not handled via UFFDIO_CONTINUE, got '%c'", c);
> +
> + SAFE_PTHREAD_JOIN(thr, NULL);
> + reset_pages();
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + /*
> + * UFFDIO_CONTINUE is available since 5.13 but
> + * UFFD_FEATURE_MINOR_SHMEM appeared in 5.14
> + */
> + .min_kver = "5.14",
Should we do a runtime check in the test setup here as well?
> + .cleanup = reset_pages,
> +};
> --
> 2.53.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-05-05 14:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 22:03 [LTP] [PATCH v3] userfaultfd: Add new test using UFFDIO_CONTINUE Ricardo Branco
2026-04-01 21:03 ` [LTP] [PATCH v4 1/2] memfd_create: move sys_memfd_create() to lapi/memfd.h Ricardo Branco
2026-04-01 21:03 ` [LTP] [PATCH v4 2/2] userfaultfd: Add new test using UFFDIO_CONTINUE Ricardo Branco
2026-04-09 14:15 ` Andrea Cervesato via ltp
2026-04-09 14:51 ` Andrea Cervesato via ltp
2026-04-09 15:19 ` [LTP] [PATCH v5 1/2] memfd_create: move sys_memfd_create() to lapi/memfd.h Ricardo Branco
2026-04-09 15:19 ` [LTP] [PATCH v5 2/2] userfaultfd: Add new test using UFFDIO_CONTINUE Ricardo Branco
2026-04-11 9:47 ` [LTP] [PATCH v6 1/2] memfd_create: move sys_memfd_create() to lapi/memfd.h Ricardo Branco
2026-04-11 9:47 ` [LTP] [PATCH v6 2/2] userfaultfd: Add new test using UFFDIO_CONTINUE Ricardo Branco
2026-04-29 14:35 ` Andrea Cervesato via ltp
2026-04-29 14:37 ` Andrea Cervesato via ltp
2026-05-05 14:12 ` Cyril Hrubis [this message]
2026-05-05 14:28 ` Ricardo Branco
2026-05-05 14:50 ` Cyril Hrubis
2026-04-11 10:44 ` [LTP] memfd_create: move sys_memfd_create() to lapi/memfd.h acervesato
2026-05-05 12:24 ` Cyril Hrubis
2026-05-05 12:22 ` [LTP] [PATCH v6 1/2] " Cyril Hrubis
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=afn62QQkJgwO28hE@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--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