Skip to contentSkip to conversation

mm/hwpoison: Add in-use hugepage hwpoison filter judgement

PATCH In review luofei 1 participant 1 message Feb 23, 2022

Subsystems (2)
lore
Share & tools
lore

luofei

author
#0 lore raw

PATCH v5 2/2 mm/hwpoison: Add in-use hugepage hwpoison filter judgement

After successfully obtaining the reference count of the huge page, it is still necessary to call hwpoison_filter() to make a filter judgement, otherwise the filter hugepage will be unmaped and the related process may be killed.

---
 mm/memory-failure.c | 8 ++++++++
 1 file changed, 8 insertions(+)
mm/memory-failure.c +8 -0
index 7e16d31df0f3..bad659092176 100644
@@ -1547,6 +1547,14 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags)
 	lock_page(head);
 	page_flags = head->flags;
 
+	if (hwpoison_filter(p)) {
+		if (TestClearPageHWPoison(head))
+			num_poisoned_pages_dec();
+		put_page(p);
+		res = -EOPNOTSUPP;
+		goto out;
+	}
+
 	/*
 	 * TODO: hwpoison for pud-sized hugetlb doesn't work right now, so
 	 * simply disable it. In order to make it work properly, we need
Signature · 1 line
2.27.0