On Fri, Mar 08, 2024 at 04:48:33PM +0800, Miaohe Lin wrote: > On 2024/3/1 5:20, Matthew Wilcox (Oracle) wrote: > > @@ -2277,8 +2277,8 @@ int memory_failure(unsigned long pfn, int flags) > > } > > } > > > > - hpage = compound_head(p); > > - if (PageTransHuge(hpage)) { > > + folio = page_folio(p); > > + if (folio_test_large(folio)) { > > /* > > * The flag must be set after the refcount is bumped > > * otherwise it may race with THP split. [...] > > @@ -2318,11 +2319,11 @@ int memory_failure(unsigned long pfn, int flags) > > * race window. If this happens, we could try again to hopefully > > * handle the page next round. > > */ > > - if (PageCompound(p)) { > > + if (folio_test_large(folio)) { > > folio_test_large() only checks whether PG_head is set but PageCompound() also checks PageTail(). > So folio_test_large() and PageCompound() are not equivalent? Assuming we have a refcount on this page so it can't be simultaneously split/freed/whatever, these three sequences are equivalent: 1 if (PageCompound(p)) 2 struct page *head = compound_head(p); 2 if (PageHead(head)) 3 struct folio *folio = page_folio(p); 3 if (folio_test_large(folio))