Re: [PATCH] mm: hugetlb: independent PMD page table shared count

From: David Hildenbrand
Date: Tue Dec 17 2024 - 06:55:47 EST


On 16.12.24 19:33, jane.chu@xxxxxxxxxx wrote:
On 12/14/2024 2:44 AM, Liu Shixin wrote:

The folio refcount may be increased unexpectly through try_get_folio() by
caller such as split_huge_pages. In huge_pmd_unshare(), we use refcount to
check whether a pmd page table is shared. The check is incorrect if the
refcount is increased by the above caller, and this can cause the page
table leaked:

hugetlb and THP don't overlap, right?  how does split_huge_pages() end
up messing up huge_pmd_share() ?

Am I missing something?


If first grabs a reference to then check if it's a THP. So we can end up grabbing anything temporarily.


In general, we'll have to be smarter about what we try grabbing, but handling races for now is tricky.

--
Cheers,

David / dhildenb