Re: [PATCH 19/21] mm/hugetlb: use the VMA lock to stabilize flags for PMD sharing

From: David Hildenbrand (Arm)

Date: Tue Dec 01 2026 - 16:03:34 EST


On 12/1/26 22:01, Suren Baghdasaryan wrote:
> On Tue, Dec 1, 2026 at 12:24 PM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
>>
>> Hi,
>>
>> thanks for the review!
>>
>>>
>>> Right, it does not block on contention, it is designed to be used in a
>>> fastpath with a fallback that would block.
>>
>> Right ... which is similar to what the hugetlb scenario wants. trylock, if it
>> fails give up.
>>
>> Just like giving up when trylocking the mmap lock fails.
>>
>>>
>>>
>>> Completely agree.
>>> This patch does not introduce a new trylock functionality. It just
>>> exposes an internal function, namely vma_start_read() to the outside
>>> world.
>>
>> I disagree. It exposes a reasonable function for a reasonable use case: try
>> grabbing the VMA lock while it is guaranteed to not go away (munmap etc
>> impossible). Just like trylocking the mmap lock.
>
> Ok, you have a point. However, the way it's implemented here isn't
> what I would call robust.
>
>>
>> BUT I agree that making this available to other users that might just abuse it
>> is not good, and the use case is likely not important enough to optimize for
>> this at this point.
>>
>> I'm sure we'll hear about this again if it affects real workloads and I'll let
>> all of you figure out a better solution then :P
>
> Perhaps knowing how the VMA is guaranteed to remain alive in a
> specific case would reveal a better API.

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 :(

--
Cheers,

David