Re: [PATCH 4/5] mm/page_vma_mapped: use huge_ptep_get() for hugetlb

From: David Hildenbrand (Arm)

Date: Mon Jun 29 2026 - 02:45:48 EST


On 6/28/26 07:44, Lance Yang wrote:
>
> On Sat, Jun 27, 2026 at 12:43:31PM +0530, Dev Jain wrote:
>>
>>
>> On 26/06/26 10:16 pm, Lance Yang wrote:
> [...]
>>>
>>> Just thinking out loud: given that huge_ptep_get() already assumes that
>>> addr matches the huge pte, at least on arm64, would it make sense to
>>> have a small hugetlb wrapper around it that takes hstate and aligns
>>> the address before calling the arch helper?
>>>
>>> Might make the rule clearer, and a bit harder to get wrong again :)
>>
>> Are you suggesting something like:
>
> Yes, that's what I had in mind :) thanks!
>
>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>> index fdb7bdf7645c..xxxxxxxxxxxx 100644
>> --- a/include/linux/hugetlb.h
>> +++ b/include/linux/hugetlb.h
>> @@ -825,6 +825,15 @@ static inline struct folio *filemap_lock_hugetlb_folio(struct hstate *h,
>>
>> #include <asm/hugetlb.h>
>
> Maybe worth spelling out the rule as well:
>
> For arch helpers that use addr, huge_ptep_get() assumes addr is the
> address for the hugetlb entry ptep points to. arm64 already makes that
> assumption.
>
> Callers where addr may not be hugepage-aligned should use
> hugetlb_ptep_get() instead.

Do we have any examples where code would do that? I would think that all code
must properly align addr ahead of times.

--
Cheers,

David