Skip to content

Commit

Permalink
mm: memory-failure: avoid false hwpoison page mapped error info
Browse files Browse the repository at this point in the history
commit faeb2ff upstream.

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: 230ac71 ("mm/hwpoison: don't try to unpoison containment-failed pages")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
MiaoheLin authored and gregkh committed Aug 16, 2023
1 parent 97d06fb commit 3a38bc2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mm/memory-failure.c
Expand Up @@ -2502,6 +2502,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);
Expand All @@ -2514,9 +2521,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)) {
Expand Down

0 comments on commit 3a38bc2

Please sign in to comment.