From: Peter Xu <peterx@redhat.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
David Hildenbrand <david@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Mike Rapoport <rppt@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Nikita Kalyazin <kalyazin@amazon.com>,
Vlastimil Babka <vbabka@suse.cz>,
Axel Rasmussen <axelrasmussen@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
James Houghton <jthoughton@google.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Hugh Dickins <hughd@google.com>, Michal Hocko <mhocko@suse.com>,
Ujwal Kundur <ujwal.kundur@gmail.com>,
Oscar Salvador <osalvador@suse.de>,
Suren Baghdasaryan <surenb@google.com>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [PATCH v4 0/4] mm/userfaultfd: modulize memory types
Date: Thu, 30 Oct 2025 17:33:31 -0400 [thread overview]
Message-ID: <aQPZqyUUVjexKWaJ@x1.local> (raw)
In-Reply-To: <bx3pshg4iwcgbzihgsoxmpubbsecgm5r2x37g3sfriloke7fk3@kbyponznh3sl>
On Thu, Oct 30, 2025 at 04:52:26PM -0400, Liam R. Howlett wrote:
> * Peter Xu <peterx@redhat.com> [251030 15:56]:
> > On Thu, Oct 30, 2025 at 03:07:18PM -0400, Peter Xu wrote:
> > > > Patches are here:
> > > >
> > > > https://git.infradead.org/?p=users/jedix/linux-maple.git;a=shortlog;h=refs/heads/modularized_mem
> > >
> > > Great! Finally we have something solid to discuss on top.
> > >
> > > Yes, I'm extremely happy to see whatever code there is, I'm happy to review
> > > it. I'm happy to see it rolling. If it is better, we can adopt it.
> >
> > So here is a summary of why I think my proposal is better:
> >
> > - Much less code
> >
> > I think this is crystal clear.. I'm pasting once more in this summary
> > email on what your proposal touches:
> >
> > fs/userfaultfd.c | 14 +--
> > include/linux/hugetlb.h | 21 ----
> > include/linux/mm.h | 11 ++
> > include/linux/shmem_fs.h | 14 ---
> > include/linux/userfaultfd_k.h | 108 ++++++++++------
> > mm/hugetlb.c | 359 +++++++++++++++++++++++++++++++++++++++++++++--------
> > mm/shmem.c | 245 ++++++++++++++++++++++++------------
> > mm/userfaultfd.c | 869 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------
> > 8 files changed, 962 insertions(+), 679 deletions(-)
>
> Including the following highlights:
> -#include <linux/hugetlb.h>
>
> and
>
> -typedef unsigned int __bitwise uffd_flags_t;
So you spent ~1000 LOC for these as highlights.. It's ok, I'll wait for a
second opinion.
>
>
> >
> > - Much less future code
> >
> > The new proposal needs at least 6 APIs to implement even minor fault..
> > One of the API needs to be implemented with uffd_info* which further
> > includes 10+ fields to process. It means we'll have a bunch of
> > duplicated code in the future if new things pop up, so it's not only
> > about what we merge.
>
> You can reuse existing functions if there is no change.
>
> >
> > - Much less exported functions to modules
>
> I haven't exported anything. You asked for code and I provided it.
> This doesn't do what guest_memfd needs as it is. This is all clean up
> you wouldn't do.
>
> >
> > My solution, after exposing vm_uffd_ops, doesn't need to export any
> > function.
> >
> > Your solution needs to export a lot of new functions to modules. I
> > didn't pay a lot of attention but the list should at least include these
> > 10 functions:
> >
> > void uffd_complete_register(struct vm_area_struct *vma);
> > unsigned int uffd_page_shift(struct vm_area_struct *vma);
> > int uffd_writeprotect(struct uffd_info *info);
> > ssize_t uffd_failed_do_unlock(struct uffd_info *info);
> > int uffd_atomic_pte_copy(struct folio *folio, unsigned long src_addr);
> > unsigned long mfill_size(struct vm_area_struct *vma)
> > int mfill_atomic_pte_poison(struct uffd_info *info);
> > int mfill_atomic_pte_copy(struct uffd_info *info);
> > int mfill_atomic_pte_zeropage(struct uffd_info *info);
> > ssize_t uffd_get_dst_pmd(struct vm_area_struct *dst_vma, unsigned long dst_addr,pmd_t **dst_pmd);
> >
> > It's simply unnecessary.
>
> Maybe we don't export any of them. Maybe there's another function
> pointer that could be checked or overwritten? We can do that without a
> flag or setting or wahtever the name you used for your flag was.
You need to export them when guest-memfd will be involved, am I right?
>
> >
> > - Less error prone
> >
> > At least to support minor fault, my solution only needs one hook fetching
> > page cache, then set the CONTINUE ioctl in the supported_ioctls.
>
> Your code just adds more junk to uffd, and fails to modularize anything
> beyond getting a folio. And you only support certain types and places.
So would CoC accepts "junk" in this context?
>
> >
> > - Safer
> >
> > Your code allows to operate on pmd* in a module??? That's too risky and
> > mm can explode! Isn't it?
>
> Again. I didn't export anything.
>
> >
> > - Do not build new codes on top of hugetlbfs
> >
> > AFAICT, more than half of your solution's API is trying to service
> > hugetlbfs. IMHO that's the wrong way to go. I explained to you multiple
> > times. We should either keep hugetlbfs alone, or having hugetlbfs adopt
> > mm APIs instead. We shouldn't build any new code only trying to service
> > hugetlbfsv1 but nobody else. We shouldn't introduce new mm API only to
> > service hugetlbfs.
>
> Ignoring hugetlb exists is a problem. I have removed the hugetlb from
> being included in uffd while you have left it in its own loop. This
> doesn't build new things on hugetlb, it moves the code for hugetlb out
> of mm/userfaultfd.c - how is it building on hugetlb?
The APIs you introduced is building for hugetlb. If without hugetlb, more
than half of the API is not needed.
>
> Believe it or not, hugetlb is a memory type.
>
> Certainly smaller changes are inherently less bug prone. I honestly
> think all of what I have here needs to be done, regardless of memfd
> support. I cannot believe that things were allowed to be pushed this
> far. I do not think they should be allowed to go further.
>
> >
> > - Much less risk of breaking things
> >
> > I'm pretty sure my code introduce zero or very little bug, if there's
> > one, I'll fix it, but really, likely not, because the changes are
> > straightforward.
> >
> > Your changes are huge. I would not be surprised you break things here
> > and there. I hope at least you will be around fixing them when it
> > happens, even if we're not sure the benefits of most of the changes.
>
> I have always been prompt in fixing my issues and have taken
> responsibility for anything I've written. I maintain the maple tree and
> other areas of mm. I have no plans of leaving Linux and I hope not to
> die.
>
> I can maintain mm/userfaultfd.c, if that helps. I didn't feel like I
> knew the area enough before, but I'm learning a lot doing this.
I'm not maintainer of userfaultfd, I'm a reviewer. I was almost just
trying to help, in reality that is also true that obviously I don't make
decisions.
I definitely think you can at least propose add yourself as a reviewer if
you like to start looking after userfaultfds, or even M if Andrew likes it.
You're already listed as core mm R so I don't see much difference if it's
only a R addition.
--
Peter Xu
next prev parent reply other threads:[~2025-10-30 21:33 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 23:14 Peter Xu
2025-10-14 23:14 ` [PATCH v4 1/4] mm: Introduce vm_uffd_ops API Peter Xu
2025-10-20 14:18 ` David Hildenbrand
2025-10-14 23:14 ` [PATCH v4 2/4] mm/shmem: Support " Peter Xu
2025-10-20 14:18 ` David Hildenbrand
2025-10-14 23:15 ` [PATCH v4 3/4] mm/hugetlb: " Peter Xu
2025-10-20 14:19 ` David Hildenbrand
2025-10-14 23:15 ` [PATCH v4 4/4] mm: Apply vm_uffd_ops API to core mm Peter Xu
2025-10-20 13:34 ` [PATCH v4 0/4] mm/userfaultfd: modulize memory types David Hildenbrand
2025-10-20 14:12 ` Peter Xu
2025-10-21 15:51 ` Liam R. Howlett
2025-10-21 16:28 ` Peter Xu
2025-10-30 17:13 ` Liam R. Howlett
2025-10-30 18:00 ` Nikita Kalyazin
2025-10-30 19:07 ` Peter Xu
2025-10-30 19:55 ` Peter Xu
2025-10-30 20:23 ` Lorenzo Stoakes
2025-10-30 21:13 ` Peter Xu
2025-10-30 21:27 ` Peter
2025-11-03 20:01 ` David Hildenbrand (Red Hat)
2025-11-03 20:46 ` Peter Xu
2025-11-03 21:27 ` David Hildenbrand (Red Hat)
2025-11-03 22:49 ` Peter Xu
2025-11-04 7:10 ` Lorenzo Stoakes
2025-11-04 14:18 ` David Hildenbrand (Red Hat)
2025-11-04 7:21 ` Mike Rapoport
2025-11-04 12:23 ` David Hildenbrand (Red Hat)
2025-11-06 16:32 ` Liam R. Howlett
2025-11-09 7:11 ` Mike Rapoport
2025-11-10 16:34 ` Liam R. Howlett
2025-11-11 10:05 ` Mike Rapoport
2025-10-30 20:52 ` Liam R. Howlett
2025-10-30 21:33 ` Peter Xu [this message]
2025-10-30 20:24 ` Liam R. Howlett
2025-10-30 21:26 ` Peter Xu
2025-11-03 16:11 ` Mike Rapoport
2025-11-03 18:43 ` Liam R. Howlett
2025-11-05 21:23 ` David Hildenbrand
2025-11-06 16:16 ` Liam R. Howlett
2025-11-07 10:16 ` David Hildenbrand (Red Hat)
2025-11-07 16:55 ` Liam R. Howlett
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=aQPZqyUUVjexKWaJ@x1.local \
--to=peterx@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=jthoughton@google.com \
--cc=kalyazin@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=ujwal.kundur@gmail.com \
--cc=vbabka@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox