]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm: memory-failure: avoid false hwpoison page mapped error info
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 27 Jul 2023 11:56:42 +0000 (19:56 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 30 Oct 2023 11:00:09 +0000 (12:00 +0100)
BugLink: https://bugs.launchpad.net/bugs/2038969
commit faeb2ff2c1c5cb60ce0da193580b256c941f99ca 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: 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>
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
mm/memory-failure.c

index 4ac8d89f2d3de45a9a30f97db900bb51b979d139..8cc9b6cc4c1e8dbf0417e8fa50c6bd520a2362a6 100644 (file)
@@ -2370,6 +2370,13 @@ int unpoison_memory(unsigned long pfn)
                goto unlock_mutex;
        }
 
+       if (PageSlab(page) || PageTable(page) || PageReserved(page))
+               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 (page_mapped(page)) {
                unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n",
                                 pfn, &unpoison_rs);
@@ -2382,9 +2389,6 @@ int unpoison_memory(unsigned long pfn)
                goto unlock_mutex;
        }
 
-       if (PageSlab(page) || PageTable(page) || PageReserved(page))
-               goto unlock_mutex;
-
        ghp = get_hwpoison_page(p, MF_UNPOISON);
        if (!ghp) {
                if (PageHuge(p)) {