Re: [PATCH v2] Documentation/userfaultfd: document RWP behavior when the PTE is dropped
From: Kiryl Shutsemau (Meta)
Date: Mon Nov 16 2026 - 11:29:03 EST
On Mon, Nov 16, 2026 at 11:09:56AM +0100, Jose A. Perez de Azpillaga wrote:
> +The registration is fixed, but the tracking mode is not: a context that
> +switches to sync mode with ``UFFDIO_SET_MODE``, as the workflow below does,
> +needs the sync registration. This has a cost in async mode, because minor
> +faults are always synchronous: an access that takes a minor fault blocks
> +until the handler resolves it, even while RWP faults are resolved by the
> +kernel.
Nitpick, and my fault: I said in v1 that the registration is fixed. It
is not. UFFDIO_REGISTER on an already registered range with the same
context can add or drop MISSING and MINOR; only dropping WP or RWP needs
an unregister first. So the cost in async mode is optional: the VMM can
add MINOR before it switches to sync and drop it after it switches back.
Maybe something like:
The registration does not follow the tracking mode: a context that
switches to sync mode with ``UFFDIO_SET_MODE``, as the workflow below
does, needs ``UFFDIO_REGISTER_MODE_MINOR`` while it is in sync mode.
Minor faults are always synchronous, so keeping it registered makes
them block in async mode as well. Re-registering the range to add
``UFFDIO_REGISTER_MODE_MINOR`` before switching to sync, and to drop
it after switching back, avoids that.
The example can stay as it is.
Otherwise:
Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
--
Kiryl Shutsemau / Kirill A. Shutemov