Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218762/?format=api
{ "id": 2218762, "url": "http://patchwork.ozlabs.org/api/patches/2218762/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260401210338.485029-2-rbranco@suse.de/", "project": { "id": 59, "url": "http://patchwork.ozlabs.org/api/projects/59/?format=api", "name": "Linux Test Project development", "link_name": "ltp", "list_id": "ltp.lists.linux.it", "list_email": "ltp@lists.linux.it", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260401210338.485029-2-rbranco@suse.de>", "list_archive_url": null, "date": "2026-04-01T21:03:34", "name": "[v4,2/2] userfaultfd: Add new test using UFFDIO_CONTINUE", "commit_ref": null, "pull_url": null, "state": "needs-review-ack", "archived": false, "hash": "c1cb3479c2587874734192741c38e3a22d0371b9", "submitter": { "id": 92484, "url": "http://patchwork.ozlabs.org/api/people/92484/?format=api", "name": "Ricardo Branco", "email": "rbranco@suse.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260401210338.485029-2-rbranco@suse.de/mbox/", "series": [ { "id": 498393, "url": "http://patchwork.ozlabs.org/api/series/498393/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=498393", "date": "2026-04-01T21:03:33", "name": "[v4,1/2] memfd_create: move sys_memfd_create() to lapi/memfd.h", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/498393/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218762/comments/", "check": "warning", "checks": "http://patchwork.ozlabs.org/api/patches/2218762/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "ltp@lists.linux.it" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "ltp@picard.linux.it" ], "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=213.254.12.146; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)", "smtp-out1.suse.de;\n\tnone" ], "Received": [ "from picard.linux.it (picard.linux.it [213.254.12.146])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmHXj5b4pz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 08:04:05 +1100 (AEDT)", "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id A308F3E65D2\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 1 Apr 2026 23:04:03 +0200 (CEST)", "from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 90E223E686E\n for <ltp@lists.linux.it>; Wed, 1 Apr 2026 23:03:45 +0200 (CEST)", "from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-2.smtp.seeweb.it (Postfix) with ESMTPS id EB14B600874\n for <ltp@lists.linux.it>; Wed, 1 Apr 2026 23:03:44 +0200 (CEST)", "from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org\n [IPv6:2a07:de40:b281:104:10:150:64:97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 53A5F4D1F6;\n Wed, 1 Apr 2026 21:03:44 +0000 (UTC)", "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 310CB4A0B0;\n Wed, 1 Apr 2026 21:03:44 +0000 (UTC)", "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id sF9PCjCIzWkMDgAAD6G6ig\n (envelope-from <rbranco@suse.de>); Wed, 01 Apr 2026 21:03:44 +0000" ], "From": "Ricardo Branco <rbranco@suse.de>", "To": "ltp@lists.linux.it", "Date": "Wed, 1 Apr 2026 23:03:34 +0200", "Message-ID": "<20260401210338.485029-2-rbranco@suse.de>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260401210338.485029-1-rbranco@suse.de>", "References": "<20260331220354.297027-1-rbranco@suse.de>\n <20260401210338.485029-1-rbranco@suse.de>", "MIME-Version": "1.0", "X-Rspamd-Pre-Result": [ "action=no action; module=replies;\n Message is reply to one we originated", "action=no action; module=replies;\n Message is reply to one we originated" ], "X-Rspamd-Server": "rspamd2.dmz-prg2.suse.org", "X-Spamd-Result": "default: False [-4.00 / 50.00];\n\tREPLY(-4.00)[]", "X-Rspamd-Queue-Id": "53A5F4D1F6", "X-Rspamd-Action": "no action", "X-Spam-Score": "-4.00", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.0 required=7.0 tests=DMARC_PASS,SPF_HELO_NONE,\n SPF_PASS shortcircuit=no autolearn=disabled version=4.0.1", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-2.smtp.seeweb.it", "X-Virus-Scanned": "clamav-milter 1.0.9 at in-2.smtp.seeweb.it", "X-Virus-Status": "Clean", "Subject": "[LTP] [PATCH v4 2/2] userfaultfd: Add new test using UFFDIO_CONTINUE", "X-BeenThere": "ltp@lists.linux.it", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Linux Test Project <ltp.lists.linux.it>", "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>", "List-Archive": "<http://lists.linux.it/pipermail/ltp/>", "List-Post": "<mailto:ltp@lists.linux.it>", "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>", "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it", "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>" }, "content": "Add test to exercise UFFDIO_CONTINUE on a shared-memory mapping with\nUFFD_PAGEFAULT_FLAG_MINOR. The test populates a memfd-backed page,\ndrops only the PTEs with MADV_DONTNEED, verifies that the resulting\nfault is reported as MINOR, updates the page cache from the handler\nthread, and resumes execution with UFFDIO_CONTINUE.\n\nSigned-off-by: Ricardo Branco <rbranco@suse.de>\n---\n include/lapi/userfaultfd.h | 1 +\n runtest/syscalls | 1 +\n .../kernel/syscalls/userfaultfd/.gitignore | 1 +\n .../kernel/syscalls/userfaultfd/Makefile | 1 +\n .../syscalls/userfaultfd/userfaultfd07.c | 152 ++++++++++++++++++\n 5 files changed, 156 insertions(+)\n create mode 100644 testcases/kernel/syscalls/userfaultfd/userfaultfd07.c", "diff": "diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h\nindex aab3890b7..c05b8dbf5 100644\n--- a/include/lapi/userfaultfd.h\n+++ b/include/lapi/userfaultfd.h\n@@ -171,6 +171,7 @@ struct uffdio_zeropage {\n #ifndef UFFD_PAGEFAULT_FLAG_MINOR\n #define UFFD_FEATURE_MINOR_HUGETLBFS\t\t(1<<9)\n #define UFFDIO_REGISTER_MODE_MINOR\t((__u64)1<<2)\n+#define UFFD_PAGEFAULT_FLAG_MINOR\t(1<<2)\n \n #define _UFFDIO_CONTINUE\t\t(0x07)\n #define UFFDIO_CONTINUE\t\t_IOWR(UFFDIO, _UFFDIO_CONTINUE,\t\\\ndiff --git a/runtest/syscalls b/runtest/syscalls\nindex 6ba0227a8..534140f42 100644\n--- a/runtest/syscalls\n+++ b/runtest/syscalls\n@@ -1780,6 +1780,7 @@ userfaultfd03 userfaultfd03\n userfaultfd04 userfaultfd04\n userfaultfd05 userfaultfd05\n userfaultfd06 userfaultfd06\n+userfaultfd07 userfaultfd07\n \n ustat01 ustat01\n ustat02 ustat02\ndiff --git a/testcases/kernel/syscalls/userfaultfd/.gitignore b/testcases/kernel/syscalls/userfaultfd/.gitignore\nindex bc32fdf3b..3478a162e 100644\n--- a/testcases/kernel/syscalls/userfaultfd/.gitignore\n+++ b/testcases/kernel/syscalls/userfaultfd/.gitignore\n@@ -4,3 +4,4 @@\n /userfaultfd04\n /userfaultfd05\n /userfaultfd06\n+/userfaultfd07\ndiff --git a/testcases/kernel/syscalls/userfaultfd/Makefile b/testcases/kernel/syscalls/userfaultfd/Makefile\nindex 3252e47df..257249e88 100644\n--- a/testcases/kernel/syscalls/userfaultfd/Makefile\n+++ b/testcases/kernel/syscalls/userfaultfd/Makefile\n@@ -17,3 +17,4 @@ userfaultfd03: CFLAGS += -pthread\n userfaultfd04: CFLAGS += -pthread\n userfaultfd05: CFLAGS += -pthread\n userfaultfd06: CFLAGS += -pthread\n+userfaultfd07: CFLAGS += -pthread\ndiff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd07.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd07.c\nnew file mode 100644\nindex 000000000..96b273262\n--- /dev/null\n+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd07.c\n@@ -0,0 +1,152 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Copyright (c) 2026 SUSE LLC\n+ * Author: Ricardo Branco <rbranco@suse.com>\n+ */\n+\n+/*\\\n+ * Force a pagefault event and handle it using :manpage:`userfaultfd(2)`\n+ * from a different thread testing UFFDIO_CONTINUE.\n+ */\n+\n+#include \"config.h\"\n+#include <poll.h>\n+#include <unistd.h>\n+#include \"tst_test.h\"\n+#include \"tst_safe_macros.h\"\n+#include \"tst_safe_prw.h\"\n+#include \"tst_safe_pthread.h\"\n+#include \"lapi/memfd.h\"\n+#include \"lapi/userfaultfd.h\"\n+#include \"lapi/syscalls.h\"\n+\n+static long page_size;\n+static char *page;\n+static int uffd = -1;\n+static int memfd = -1;\n+\n+static void set_pages(void)\n+{\n+\tchar ch = 'A';\n+\n+\tpage_size = SAFE_SYSCONF(_SC_PAGE_SIZE);\n+\n+\tmemfd = sys_memfd_create(\"ltp-uffd-continue\", MFD_CLOEXEC);\n+\tif (memfd < 0)\n+\t\ttst_brk(TBROK | TERRNO, \"memfd_create failed\");\n+\n+\tSAFE_FTRUNCATE(memfd, page_size);\n+\n+\t/*\n+\t * Populate page cache so that after MADV_DONTNEED the next access\n+\t * can generate a MINOR fault rather than a MISSING fault.\n+\t */\n+\tSAFE_PWRITE(1, memfd, &ch, 1, 0);\n+\n+\tpage = SAFE_MMAP(NULL, page_size, PROT_READ, MAP_SHARED, memfd, 0);\n+}\n+\n+static void reset_pages(void)\n+{\n+\tif (page) {\n+\t\tSAFE_MUNMAP(page, page_size);\n+\t\tpage = NULL;\n+\t}\n+\n+\tif (memfd != -1)\n+\t\tSAFE_CLOSE(memfd);\n+\n+\tif (uffd != -1)\n+\t\tSAFE_CLOSE(uffd);\n+}\n+\n+static void *handle_thread(void *arg LTP_ATTRIBUTE_UNUSED)\n+{\n+\tstatic struct uffd_msg msg;\n+\tstruct uffdio_continue uffdio_continue = {};\n+\tstruct pollfd pollfd;\n+\tint nready;\n+\tchar z = 'Z';\n+\n+\tpollfd.fd = uffd;\n+\tpollfd.events = POLLIN;\n+\tnready = poll(&pollfd, 1, -1);\n+\tif (nready == -1)\n+\t\ttst_brk(TBROK | TERRNO, \"Error on poll\");\n+\n+\tSAFE_READ(1, uffd, &msg, sizeof(msg));\n+\n+\tif (msg.event != UFFD_EVENT_PAGEFAULT)\n+\t\ttst_brk(TFAIL, \"Received unexpected UFFD_EVENT %d\", msg.event);\n+\n+\tif (!(msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_MINOR)) {\n+\t\ttst_brk(TBROK, \"expected MINOR fault, got flags=0x%llx\",\n+\t\t\t(unsigned long long)msg.arg.pagefault.flags);\n+\t}\n+\n+\t/* Update the shmem page in page cache before resuming the fault. */\n+\tSAFE_PWRITE(1, memfd, &z, 1, 0);\n+\n+\tuffdio_continue.range.start =\n+\t\tmsg.arg.pagefault.address & ~((unsigned long)page_size - 1);\n+\tuffdio_continue.range.len = page_size;\n+\n+\tSAFE_IOCTL(uffd, UFFDIO_CONTINUE, &uffdio_continue);\n+\n+\tSAFE_CLOSE(uffd);\n+\treturn NULL;\n+}\n+\n+static void run(void)\n+{\n+\tpthread_t thr;\n+\tstruct uffdio_api uffdio_api = {};\n+\tstruct uffdio_register uffdio_register;\n+\n+\tset_pages();\n+\n+\tuffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, true);\n+\n+\tuffdio_api.api = UFFD_API;\n+\tuffdio_api.features = UFFD_FEATURE_MINOR_SHMEM;\n+\n+\tSAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);\n+\n+\tif (!(uffdio_api.features & UFFD_FEATURE_MINOR_SHMEM))\n+\t\ttst_brk(TCONF, \"UFFD_FEATURE_MINOR_SHMEM not supported\");\n+\n+\tuffdio_register.range.start = (unsigned long) page;\n+\tuffdio_register.range.len = page_size;\n+\tuffdio_register.mode = UFFDIO_REGISTER_MODE_MINOR;\n+\n+\tSAFE_IOCTL(uffd, UFFDIO_REGISTER, &uffdio_register);\n+\n+\t/*\n+\t * Drop PTEs while retaining the cached shmem page so the next access\n+\t * faults in MINOR mode.\n+\t */\n+\tif (madvise(page, page_size, MADV_DONTNEED) < 0)\n+\t\ttst_brk(TBROK | TERRNO, \"madvise MADV_DONTNEED failed\");\n+\n+\tSAFE_PTHREAD_CREATE(&thr, NULL, (void *) handle_thread, NULL);\n+\n+\tchar c = page[0];\n+\n+\tif (c == 'Z')\n+\t\ttst_res(TPASS, \"Pagefault handled via UFFDIO_CONTINUE\");\n+\telse\n+\t\ttst_res(TFAIL, \"pagefault not handled via UFFDIO_CONTINUE, got '%c'\", c);\n+\n+\tSAFE_PTHREAD_JOIN(thr, NULL);\n+\treset_pages();\n+}\n+\n+static struct tst_test test = {\n+\t.test_all = run,\n+\t/*\n+\t * UFFDIO_CONTINUE is available since 5.13 but\n+\t * UFFD_FEATURE_MINOR_SHMEM appeared in 5.14\n+\t */\n+\t.min_kver = \"5.14\",\n+\t.cleanup = reset_pages,\n+};\n", "prefixes": [ "v4", "2/2" ] }