Re: [PATCH v2 05/11] hugetlb: Convert the vmf->pgoff to PAGE_SIZE granularity

From: Matthew Wilcox

Date: Wed Jun 17 2026 - 18:28:40 EST


On Wed, Jun 17, 2026 at 11:25:26AM -0600, Jane Chu wrote:
> +++ b/mm/hugetlb.c
> @@ -5654,6 +5654,8 @@ static inline vm_fault_t hugetlb_handle_userfault(struct vm_fault *vmf,
> unsigned long reason)
> {
> u32 hash;
> + struct hstate *h = hstate_vma(vmf->vma);
> + pgoff_t idx = vmf->pgoff >> huge_page_order(h);

If we do manage to make mapping_min_folio_nrpages() return the right
answer for hugetlbfs (see earlier comment), then we can avoid this by doing:

+++ b/mm/hugetlb.c
@@ -5936,7 +5936,7 @@ u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx)
u32 hash;

key[0] = (unsigned long) mapping;
- key[1] = idx;
+ key[1] = idx >> mapping_min_folio_order(mapping);

hash = jhash2((u32 *)&key, sizeof(key)/(sizeof(u32)), 0);

although I wonder if we still need the fault mutex array, given that we
now have mapping->invalidate_lock?