Re: [PATCH 1/5] hugetlb: Make folio_test_hugetlb safer to call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 01, 2024 at 09:47:06PM +0000, Matthew Wilcox (Oracle) wrote:
> At least two places (memory failure and page migration) need to call
> folio_test_hugetlb() without a reference on the folio.  This can currently
> result in false positives (returning true when the folio doesn't belong
> to hugetlb) and more commonly in VM_BUG_ON() when a folio is split.
> 
> The new way to distinguish a hugetlb folio is to see if (1) the page
> is compound (or the folio is large) and (2) page[1].mapping is set to
> the address of hugetlb_lock.  If the folio is (or has been) large then
> page[1] is guaranteed to exist.  If the folio is split between the two
> tests, page[1].mapping will be set to something which definitely isn't
> the address of hugetlb_lock.
> 
> Because we shift around the layout of struct folio a bit, we now use
> page[1].private, which means we need to adjust __split_huge_page_tail()
> a little.  We also need to annoy the vmcore_info people again.  Sorry.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>

Thanks for working on this Willy!

I thought about whether we want a Fixes tag here, but since we are only
bugging under DEBUG_VM, and the false positives/negatives can be
rechecked under the lock, I guess it does not matter:


Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
 

-- 
Oscar Salvador
SUSE Labs




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux