If any page of a folio is poisoned, try_to_unmap() is called with the intent to remove any mappings pointing to any part of the folio. Therefore, an hwpoison check on a single page does not make sense (although everything works out because the memory-failure path sets hwpoison on the head page too). Convert these checks to check whether the folio has at least one hwpoisoned page. While at it, convert VM_BUG_* to VM_WARN_*. Signed-off-by: Dev Jain --- mm/rmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index fb3c351f8c458..430c91c8fe2ae 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2116,10 +2116,11 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, bool anon = folio_test_anon(folio); /* - * The try_to_unmap() is only passed a hugetlb page - * in the case where the hugetlb page is poisoned. + * The try_to_unmap() is only passed a hugetlb folio + * in the case where the hugetlb folio contains a + * poisoned page. */ - VM_BUG_ON_PAGE(!PageHWPoison(subpage), subpage); + VM_WARN_ON_FOLIO(!folio_contain_hwpoisoned_page(folio), folio); /* * huge_pmd_unshare may unmap an entire PMD page. * There is no way of knowing exactly which PMDs may @@ -2198,7 +2199,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, /* Update high watermark before we lower rss */ update_hiwater_rss(mm); - if (PageHWPoison(subpage) && (flags & TTU_HWPOISON)) { + if (folio_contain_hwpoisoned_page(folio) && (flags & TTU_HWPOISON)) { pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); if (folio_test_hugetlb(folio)) { hugetlb_count_sub(folio_nr_pages(folio), mm); -- 2.34.1