Re: [PATCH v4] mm/userfaultfd: fix hugetlb fault mutex hash calculation

From: Jianhui Zhou

Date: Wed Mar 11 2026 - 06:53:16 EST


On Tue, Mar 10, 2026 at 12:47:07PM -0700, jane.chu@xxxxxxxxxx wrote:
> Just wondering whether making the shift explicit here instead of
> introducing another hugetlb helper might be sufficient?
>
> idx >>= huge_page_order(hstate_vma(vma));

That would work for hugetlb VMAs since both (address - vm_start) and
vm_pgoff are guaranteed to be huge page aligned. However, David
suggested introducing hugetlb_linear_page_index() to provide a cleaner
API that mirrors linear_page_index(), so I kept this approach.

Thanks for the review!