Re: [PATCH v2 27/35] mm/hugetlb: only check PMD table sharing for PMD-sized folios
From: Jose A. Perez de Azpillaga
Date: Fri Dec 04 2026 - 06:35:33 EST
On 12/3/26 12:37 PM, David Hildenbrand (Arm) 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>
> Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a