Skip to content

Commit faeb2ff

Browse files
MiaoheLinakpm00
authored andcommitted
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/[email protected] Fixes: 230ac71 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Acked-by: Naoya Horiguchi <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f29623e commit faeb2ff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mm/memory-failure.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,13 @@ int unpoison_memory(unsigned long pfn)
24992499
goto unlock_mutex;
25002500
}
25012501

2502+
if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio))
2503+
goto unlock_mutex;
2504+
2505+
/*
2506+
* Note that folio->_mapcount is overloaded in SLAB, so the simple test
2507+
* in folio_mapped() has to be done after folio_test_slab() is checked.
2508+
*/
25022509
if (folio_mapped(folio)) {
25032510
unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n",
25042511
pfn, &unpoison_rs);
@@ -2511,9 +2518,6 @@ int unpoison_memory(unsigned long pfn)
25112518
goto unlock_mutex;
25122519
}
25132520

2514-
if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio))
2515-
goto unlock_mutex;
2516-
25172521
ghp = get_hwpoison_page(p, MF_UNPOISON);
25182522
if (!ghp) {
25192523
if (PageHuge(p)) {

0 commit comments

Comments
 (0)