Re: [PATCH 0/4] mm/userfaultfd: modulize memory types

From: Peter Xu
Date: Wed Jun 25 2025 - 16:17:38 EST


On Wed, Jun 25, 2025 at 05:56:23PM +0100, Nikita Kalyazin wrote:
>
>
> On 20/06/2025 20:03, Peter Xu wrote:
> > [based on akpm/mm-new]
> >
> > This series is an alternative proposal of what Nikita proposed here on the
> > initial three patches:
> >
> > https://lore.kernel.org/r/20250404154352.23078-1-kalyazin@xxxxxxxxxx
> >
> > This is not yet relevant to any guest-memfd support, but paving way for it.
>
> Hi Peter,

Hi, Nikita,

>
> Thanks for posting this. I confirmed that minor fault handling was working
> for guest_memfd based on this series and looked simple (a draft based on
> mmap support in guest_memfd v7 [1]):

Thanks for the quick spin, glad to know it works. Some trivial things to
mention below..

>
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 5abb6d52a375..6ddc73419724 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -5,6 +5,9 @@
> #include <linux/pagemap.h>
> #include <linux/anon_inodes.h>
> #include <linux/set_memory.h>
> +#ifdef CONFIG_USERFAULTFD

This ifdef not needed, userfaultfd_k.h has taken care of all cases.

> +#include <linux/userfaultfd_k.h>
> +#endif
>
> #include "kvm_mm.h"
>
> @@ -396,6 +399,14 @@ static vm_fault_t kvm_gmem_fault(struct vm_fault *vmf)
> kvm_gmem_mark_prepared(folio);
> }
>
> +#ifdef CONFIG_USERFAULTFD

Same here. userfaultfd_minor() is always defined.

I'll wait for a few more days for reviewers, and likely send v2 before next
week.

Thanks,

--
Peter Xu