Message ID | 20230715031729.2420338-4-linmiaohe@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | A few fixup and cleanup patches for memory-failure | expand |
On Sat, Jul 15, 2023 at 11:17:28AM +0800, Miaohe Lin wrote: > 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. > > Fixes: 230ac719c500 ("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>
On Sat, Jul 15, 2023 at 11:17:28AM +0800, Miaohe Lin wrote: > 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. > > Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ac074f82f5b3..42e63b0ab5f7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2513,6 +2513,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); @@ -2525,9 +2532,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; - ret = get_hwpoison_page(p, MF_UNPOISON); if (!ret) { if (PageHuge(p)) {
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. Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> --- mm/memory-failure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)