Commit faeb2ff2 authored by Miaohe Lin's avatar Miaohe Lin Committed by Andrew Morton
Browse files

mm: memory-failure: avoid false hwpoison page mapped error info

folio->_mapcount is overloaded in SLAB, so folio_mapped() has to be done
after folio_test_slab() is checked. Otherwise slab folio might be treated
as a mapped folio leading to false 'Someone maps the hwpoison page' error
info.

Link: https://lkml.kernel.org/r/20230727115643.639741-4-linmiaohe@huawei.com


Fixes: 230ac719 ("mm/hwpoison: don't try to unpoison containment-failed pages")
Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f29623e4
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2499,6 +2499,13 @@ int unpoison_memory(unsigned long pfn)
		goto unlock_mutex;
	}

	if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio))
		goto unlock_mutex;

	/*
	 * Note that folio->_mapcount is overloaded in SLAB, so the simple test
	 * in folio_mapped() has to be done after folio_test_slab() is checked.
	 */
	if (folio_mapped(folio)) {
		unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n",
				 pfn, &unpoison_rs);
@@ -2511,9 +2518,6 @@ int unpoison_memory(unsigned long pfn)
		goto unlock_mutex;
	}

	if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio))
		goto unlock_mutex;

	ghp = get_hwpoison_page(p, MF_UNPOISON);
	if (!ghp) {
		if (PageHuge(p)) {