All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	mm-commits@vger.kernel.org, vladimirelitokarev@gmail.com,
	viro@zeniv.linux.org.uk, stable@vger.kernel.org,
	peterx@redhat.com, oleg@redhat.com, jack@suse.cz,
	brauner@kernel.org, rppt@kernel.org,
	"Lorenzo Stoakes (Oracle)" <ljs@kernel.org>
Subject: Re: + userfaultfd-prevent-registration-of-special-vmas.patch added to mm-hotfixes-unstable branch
Date: Fri, 19 Jun 2026 09:53:43 +0200	[thread overview]
Message-ID: <cb30b646-31a0-4afe-aba2-3cb01f299c00@kernel.org> (raw)
In-Reply-To: <CAHk-=wjWhvmy5xUcTMCJZats2cUJ5iGU4o5Kdt+OvRepu+MUeQ@mail.gmail.com>

On 6/18/26 23:42, Linus Torvalds wrote:
> On Thu, 18 Jun 2026 at 14:07, David Hildenbrand (Arm) <david@kernel.org> wrote:
>>
>> Maybe we should rename and possibly split that up, like
>>
>>         VM_NO_MLOCK
>>         VM_NO_VMA_MERGE
> 
> That sounds saner, indeed.
> 
>> And then have some generic "there are really special things mapped in here"
>>
>>         VM_HAS_SPECIAL_MAPPINGS
> 
> I think maybe we should stop using "bitmasks of VM_xyz bits" and start
> moving to a "helper inlines for vma testing".

100%

> 
> That way we could make hugetlb not set DONTEXPAND at all, if we
> instead just introduce a
> 
>    static inline bool vma_can_merge(const struct vm_area_struct *vma)
>    {
>         if (vma->vm_flags & VM_SPECIAL)
>                 return false;
>         if (vma_is_hugetlb(vma))
>                 return false;
>         return true;
>     }

Yes. DONTEXPAND is a weird thing and I am afraid it's getting abused at other
places.

> 
> Ok, so that vma_is_hugetlb() thing doesn'ty exist - but we do have a

We have is_vm_hugetlb_page() that we should probably rename.

We probably need helpers for VMA vs. VMA flags, but I'd let Lorenzo figure that
out. (CC)

> VMA_HUGETLB_BIT to implement it. I wrote it that way mainly in an
> effort to make it all make sense logically.
> 
> And maybe we could get rid of VM_SPECIAL entirely at some point usign
> these kinds of helpers - by making "vma_can_merge()" and others that
> currently use VM_SPECIAL use the *actual* real bits explicitly and
> simply making each rule have simple and logical tests.

Yes. Or make them build on each other (vma_maps_special_pages() or whatever)

> 
> And the reason we should pass in the vma - not just vm_flags - is that
> often things like "is the vma anonymous" is part of the decision of
> what can be done.

Right, I think the problem is that sometimes (VMA modifications) we might have
the updated flags but not the updated VMA. But again, I'm sure Lorenzo could
figure that out.

> 
> I think this would make the code both more flexible _and_ more
> understandable if we had these kinds of helpers for different
> situations rather than have VM_SPECIAL kinds of flag combinations.
> 
> But I'm just throwing this out as an idea. Maybe there are better ways
> to deal with this. The current code does seem rather annoying.

Yes, thanks for raising that; it needs a proper rework with clear semantics.

-- 
Cheers,

David

  reply	other threads:[~2026-06-19  7:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 18:34 + userfaultfd-prevent-registration-of-special-vmas.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-06-18 19:25 ` Linus Torvalds
2026-06-18 21:07   ` David Hildenbrand (Arm)
2026-06-18 21:42     ` Linus Torvalds
2026-06-19  7:53       ` David Hildenbrand (Arm) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-17 19:45 Andrew Morton

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=cb30b646-31a0-4afe-aba2-3cb01f299c00@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=ljs@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linuxfoundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vladimirelitokarev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.