From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,rppt@kernel.org,peterx@redhat.com,
david@kernel.org,corbet@lwn.net,akpm@linux-foundation.org,
kmehltretter@gmail.com
Subject: + userfaultfd-docs-fix-an-error-code-two-names-and-the-pollerr-cause.patch added to mm-new branch
Date: Fri, 30 Oct 2026 15:26:16 -0700 [thread overview]
Message-ID: <20261030222617.694331F000C1@smtp.kernel.org> (raw)
The patch titled
Subject: userfaultfd: docs: fix an error code, two names and the POLLERR cause
has been added to the -mm mm-new branch. Its filename is
userfaultfd-docs-fix-an-error-code-two-names-and-the-pollerr-cause.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/userfaultfd-docs-fix-an-error-code-two-names-and-the-pollerr-cause.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Karl Mehltretter <kmehltretter@gmail.com>
Subject: userfaultfd: docs: fix an error code, two names and the POLLERR cause
Date: Sat, 3 Oct 2026 13:01:37 +0200
Four statements in userfaultfd.rst do not match the code:
- UFFDIO_COPY is said to return -ENOSPC when the monitored process
exits at the time of the copy. That error is -ESRCH since
commit e86b298bebf7 ("userfaultfd: replace ENOSPC with ESRCH in case
mm has gone during copy/zeropage"), and userfaultfd_copy() still
returns -ESRCH when mmget_not_zero() fails.
- the postcopy example says that UFFDIO_ZEROCOPY is used for zero pages.
The ioctl is UFFDIO_ZEROPAGE, as the same sentence says a line
earlier.
- the write protect section says to clear UFFDIO_WRITEPROTECT_MODE_WP in
pagefault.mode. struct uffd_msg's pagefault has no mode field. The
flag goes in the mode field of struct uffdio_writeprotect, as the
paragraph says when it sets the flag.
- poll() is said to report POLLERR "when ranges supplied were
incorrect". userfaultfd_poll() never looks at ranges, and an ioctl
with a bad range fails on its own. It returns EPOLLERR when the
UFFDIO_API handshake has not been done yet and when the file does not
have O_NONBLOCK set, and it did so when the sentence was written.
Say -ESRCH, UFFDIO_ZEROPAGE and mode, and name the two POLLERR cases.
Link: https://lore.kernel.org/20261003110137.88619-1-kmehltretter@gmail.com
Fixes: e86b298bebf7 ("userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage")
Fixes: 25edd8bffd0f ("userfaultfd: linux/Documentation/vm/userfaultfd.txt")
Fixes: 57e5d4f278b9 ("userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
---
Documentation/admin-guide/mm/userfaultfd.rst | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--- a/Documentation/admin-guide/mm/userfaultfd.rst~userfaultfd-docs-fix-an-error-code-two-names-and-the-pollerr-cause
+++ a/Documentation/admin-guide/mm/userfaultfd.rst
@@ -199,8 +199,9 @@ Notes:
those IOCTLs wakes up the faulting thread.
- Be sure to test for all errors including
- (``pollfd[0].revents & POLLERR``). This can happen, e.g. when ranges
- supplied were incorrect.
+ (``pollfd[0].revents & POLLERR``). This happens if the userfaultfd
+ does not have ``O_NONBLOCK`` set, or if it is polled before the
+ ``UFFDIO_API`` handshake.
Write Protect Notifications
---------------------------
@@ -218,7 +219,7 @@ protect as many ranges as you like (insi
Then, in the thread reading from uffd the struct will have
``msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WP`` set. Now you send
``ioctl(uffd, UFFDIO_WRITEPROTECT, struct *uffdio_writeprotect)``
-again while ``pagefault.mode`` does not have ``UFFDIO_WRITEPROTECT_MODE_WP``
+again while ``mode`` does not have ``UFFDIO_WRITEPROTECT_MODE_WP``
set. This wakes up the thread which will continue to run with writes. This
allows you to do the bookkeeping about the write in the uffd reading
thread before the ioctl.
@@ -584,7 +585,7 @@ The QEMU in the source node writes all p
in the destination node, into the socket, and the migration thread of
the QEMU running in the destination node runs ``UFFDIO_COPY|ZEROPAGE``
ioctls on the ``userfaultfd`` in order to map the received pages into the
-guest (``UFFDIO_ZEROCOPY`` is used if the source page was a zero page).
+guest (``UFFDIO_ZEROPAGE`` is used if the source page was a zero page).
A different postcopy thread in the destination node listens with
poll() to the ``userfaultfd`` in parallel. When a ``POLLIN`` event is
@@ -672,7 +673,7 @@ asynchronously and the non-cooperative p
soon as manager executes read(). The ``userfaultfd`` manager should
carefully synchronize calls to ``UFFDIO_COPY`` with the events
processing. To aid the synchronization, the ``UFFDIO_COPY`` ioctl will
-return ``-ENOSPC`` when the monitored process exits at the time of
+return ``-ESRCH`` when the monitored process exits at the time of
``UFFDIO_COPY``, and ``-ENOENT``, when the non-cooperative process has changed
its virtual memory layout simultaneously with outstanding ``UFFDIO_COPY``
operation.
_
Patches currently in -mm which might be from kmehltretter@gmail.com are
userfaultfd-docs-fix-an-error-code-two-names-and-the-pollerr-cause.patch
squashfs-fix-fragment-index-table-sizing-overflow-on-32-bit.patch
squashfs-make-the-fragment-index-table-bounds-check-overflow-safe.patch
reply other threads:[~2026-10-30 22:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261030222617.694331F000C1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=kmehltretter@gmail.com \
--cc=mm-commits@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=rppt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.