Re: [PATCH v2] mm: migrate: fix missing update page_private to hugetlb_page_subpool

From: Anshuman Khandual
Date: Fri May 21 2021 - 03:25:28 EST




On 5/21/21 7:57 AM, Muchun Song wrote:
> Since commit d6995da31122 ("hugetlb: use page.private for hugetlb specific
> page flags") converts page.private for hugetlb specific page flags. We
> should use hugetlb_page_subpool() to get the subpool pointer instead of
> page_private().
>
> This 'could' prevent the migration of hugetlb pages. page_private(hpage)
> is now used for hugetlb page specific flags. At migration time, the
> only flag which could be set is HPageVmemmapOptimized. This flag will
> only be set if the new vmemmap reduction feature is enabled. In
> addition, !page_mapping() implies an anonymous mapping. So, this will
> prevent migration of hugetb pages in anonymous mappings if the vmemmap
> reduction feature is enabled.
>
> In addition, that if statement checked for the rare race condition of a
> page being migrated while in the process of being freed. Since that
> check is now wrong, we could leak hugetlb subpool usage counts.
>
> The commit forgot to update it in the page migration routine. So fix it.
>
> Fixes: d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags")
> Reported-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
> Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>

Tested on all page size configs and HugeTLB migrations work as expected.

Tested-by: Anshuman Khandual <anshuman.khandual@xxxxxxx> #arm64