diff mbox series

答复: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page

Message ID 85ab16d0a56c4942bb8a3e67b9d55858@unicloud.com (mailing list archive)
State New
Headers show
Series 答复: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page | expand

Commit Message

luofei Aug. 4, 2022, 12:07 p.m. UTC
Sorry, wrong patch, please ignore this email.
diff mbox series

Patch

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 14439806b5ef..fc571b0ceb9d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2293,6 +2293,28 @@  core_initcall(memory_failure_init);
                pr_info(fmt, pfn);                      \
 })

+static bool hugetlb_page_head_poison(struct page *hpage, struct page *page)
+{
+       struct llist_head *head;
+       struct llist_node *t, *tnode;
+       struct raw_hwp_page *p;
+
+       if (PageHuge(page) && PageHWPoison(hpage) && HPageFreed(hpage))
+               return false;
+
+       if (HPageRawHwpUnreliable(hpage))
+               return false;
+
+       head = raw_hwp_list_head(hpage);
+       llist_for_each_safe(tnode, t, head->first) {
+               p = container_of(tnode, struct raw_hwp_page, node);
+               if (p->page == page)
+                       return true;
+       }
+
+       return false;
+}
+
 /**
  * unpoison_memory - Unpoison a previously poisoned page
  * @pfn: Page number of the to be unpoisoned page
@@ -2330,7 +2352,7 @@  int unpoison_memory(unsigned long pfn)
                goto unlock_mutex;
        }

-       if (!PageHWPoison(p)) {
+       if (!PageHWPoison(p) && !hugetlb_page_head_poison(page, p)) {
                unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n",
                                 pfn, &unpoison_rs);
                goto unlock_mutex;