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

From: Peter Xu

Date: Thu Oct 30 2025 - 17:26:34 EST


Let me reply in short.

On Thu, Oct 30, 2025 at 04:24:46PM -0400, Liam R. Howlett wrote:
> Right, so the existing code a huge mess today and you won't fix
> anything, ever.

IMHO fix is the wrong word. Cleanup it is. I agree the current
userfaultfd code isn't extremely easy to follow.

>
> We currently have a uffd_flags_t that sets wp or not then passes it
> through to set another part of the flag to pass it through again. This
> is stupid.

I feel like you're applying very strongly personal preference to this piece
of code. I won't say that is stupid. Axel introduced it, and I think it's
still an improvement comparing to before.

>
> And then it gets more stupid. We then check that flag exactly once for
> the second argument in a global function and NEVER LOOK AT THAT PART
> AGAIN. So we now have a type to contain a boolean, but we keep passing
> through the uffd_flags_t, so we can see if wp is set or not.
>
> And you're fine with it. In fact, let's add another one. I mean, we
> tried for two but people didn't like two so lets whine and whine and
> whine until people get frustrated and let you push a second one of those
> gems into the code you REFUSED TO MAINTAIN.

What I refuse to maintain? I don't really follow.

>
> This is what owning a problem looks like: I removed the uufd_flags_t,
> because it's stupid. I removed all the hugetlb checks because I
> modularized the memory types.
>
> I'm happy to address changes, but I'm not happy to accept more
> middleware and "it's not part of the patch set" to address any problem
> as you push more trash into an already horrible code base.
>
> We need to fix things too.
>
> So I'm fixing it.

Let's wait for a 2nd opinion on the approaches.

As I said, I'm OK if everyone likes your solution and if I'm the only one
NACKing it. If we can support guest-memfd finally whoever adds that, it's
not so bad.

--
Peter Xu