Re: [PATCH 10/21] mm/hugetlb: only check PMD table sharing for PMD-sized folios

From: Muchun Song

Date: Wed Nov 25 2026 - 21:09:27 EST




> On Nov 26, 2026, at 06:33, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> hugetlb_pmd_shared() reads "pt_share_count" from the ptdesc of the page
> table that maps a hugetlb folio, independent of the folio size, to tell
> whether that page table is shared. Only PMD tables have a valid
> "pt_share_count"; for other folio sizes, such as 1 GiB folios on x86
> that are mapped by a PUD table, we read whatever another user of the
> union left behind.
>
> As a result, such folios might be reported as shared in smaps and as not
> exclusively mapped in pagemap, and mbind(MPOL_MF_MOVE) and
> migrate_pages() might skip them.
>
> Let's fix it by adding hugetlb_folio_maybe_mapped_shared(), which
> combines folio_maybe_mapped_shared(), documented to not care about page
> table sharing, with a check for PMD table sharing only for PMD-sized
> folios, and using it in the affected callers.
>
> This has low urgency.
>
> Fixes: ca1a47cd3f5f ("mm/hugetlb: fix hugetlb_pmd_shared()")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>