Re: [PATCH v3 07/15] userfaultfd: introduce vm_uffd_ops

From: Matthew Wilcox

Date: Mon Mar 30 2026 - 12:58:53 EST


On Mon, Mar 30, 2026 at 01:11:08PM +0300, Mike Rapoport wrote:
> First, there is no fundamental reason to limit userfaultfd support only to
> the core memory types and userfaults can be handled similarly to regular
> page faults provided a VMA owner implements appropriate callbacks.
>
> Second, historically various code paths were conditioned on
> vma_is_anonymous(), vma_is_shmem() and is_vm_hugetlb_page() and some of
> these conditions can be expressed as operations implemented by a
> particular memory type.
>
> Introduce vm_uffd_ops extension to vm_operations_struct that will delegate
> memory type specific operations to a VMA owner.

But the VMA owner already gets control of the page fault. We don't need
the vm_uffd_ops to be accessible from the vm_operations_struct. The
page faullt handler can pass a vm_uffd_ops into the uffd functions that
it calls.