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 - 15:24:44 EST


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.

>
>>
>> Right now lock_vma_under_rcu() is the way (TM) to get a VMA lock without an
>> mmap lock already held. For now I'd like to maintain it as that.
>
> 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.

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

Thanks!

--
Cheers,

David