Re: [PATCH 19/21] mm/hugetlb: use the VMA lock to stabilize flags for PMD sharing
From: Lorenzo Stoakes (ARM)
Date: Wed Dec 02 2026 - 14:25:50 EST
On Tue, Dec 01, 2026 at 03:03:06PM -0800, Suren Baghdasaryan wrote:
> > It's hard here: we hold the i_mmap lock, which guarantees for hugetlb PMD
> > sharing that the VMA can't go away.
> >
> > That's very very special :(
>
> Indeed, that's quite an unusual way of stabilizing a VMA...
>
> Sounds like this is an outlier and not really a performance-critical
> case (I might be wrong, so feel free to correct me). If we get more
> compelling cases, a dedicated API sounds reasonable. Ideally it would
> include assertions for the proper locks that stabilize the VMA.
We've literally already seen a case with BPF doing something broken that forced
us to change core mm. It's not a theoretical risk :)
And it ends up being VMA people who have to deal with it.
So anything like this would have to be explicit, i.e. a variant of a VMA lock
that takes or at least asserts the required lock.
Hugetlb is obviously not a great example as it's doing a lot of things you're
not supposed to do (their own variety of 'VMA locks' especially) and 'gets away
with it' because it's historical.
--
Cheers, Lorenzo