]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm/memory-failure: check the mapcount of the precise page
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 18 Dec 2023 13:58:36 +0000 (13:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Jan 2024 17:51:21 +0000 (18:51 +0100)
[ Upstream commit c79c5a0a00a9457718056b588f312baadf44e471 ]

A process may map only some of the pages in a folio, and might be missed
if it maps the poisoned page but not the head page.  Or it might be
unnecessarily hit if it maps the head page, but not the poisoned page.

Link: https://lkml.kernel.org/r/20231218135837.3310403-3-willy@infradead.org
Fixes: 7af446a841a2 ("HWPOISON, hugetlb: enable error handling path for hugepage")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mm/memory-failure.c

index bcd71d8736be52cd86870e68f848d3d65f3bab1b..1f23baa98ee9b2018a6218ac2aadedb6376b1144 100644 (file)
@@ -1331,7 +1331,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
         * This check implies we don't kill processes if their pages
         * are in the swap cache early. Those are always late kills.
         */
-       if (!page_mapped(hpage))
+       if (!page_mapped(p))
                return true;
 
        if (PageKsm(p)) {
@@ -1397,10 +1397,10 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
                }
        }
 
-       unmap_success = !page_mapped(hpage);
+       unmap_success = !page_mapped(p);
        if (!unmap_success)
                pr_err("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n",
-                      pfn, page_mapcount(hpage));
+                      pfn, page_mapcount(p));
 
        /*
         * try_to_unmap() might put mlocked page in lru cache, so call