]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm, hwpoison: kill procs if unmap fails
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 18 Aug 2022 13:00:15 +0000 (21:00 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Aug 2022 05:03:06 +0000 (22:03 -0700)
If try_to_unmap() fails, the hwpoisoned page still resides in the address
space of some processes.  We should kill these processes or the hwpoisoned
page might be consumed later.  collect_procs() is always called to collect
relevant processes now so they can be killed later if unmap fails.

Link: https://lkml.kernel.org/r/20220818130016.45313-6-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c

index e13fd04a84b7df1f0363c7553a2759a10b12df03..8eefdd58a323a1a5605e6169fcbb54b8d0462b11 100644 (file)
@@ -1397,7 +1397,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
        struct address_space *mapping;
        LIST_HEAD(tokill);
        bool unmap_success;
-       int kill = 1, forcekill;
+       int forcekill;
        bool mlocked = PageMlocked(hpage);
 
        /*
@@ -1438,7 +1438,6 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
                if (page_mkclean(hpage)) {
                        SetPageDirty(hpage);
                } else {
-                       kill = 0;
                        ttu |= TTU_IGNORE_HWPOISON;
                        pr_info("%#lx: corrupted page was clean: dropped without side effects\n",
                                pfn);
@@ -1453,8 +1452,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
         * Error handling: We ignore errors here because
         * there's nothing that can be done.
         */
-       if (kill)
-               collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
+       collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED);
 
        if (PageHuge(hpage) && !PageAnon(hpage)) {
                /*
@@ -1496,7 +1494,8 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
         * use a more force-full uncatchable kill to prevent
         * any accesses to the poisoned memory.
         */
-       forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL);
+       forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL) ||
+                   !unmap_success;
        kill_procs(&tokill, forcekill, !unmap_success, pfn, flags);
 
        return unmap_success;