Skip to contentSkip to conversation

hw/poison: Add in-use hugepage hwpoison filter judgement

PATCH Superseded luofei 2 participants 2 messages Feb 18, 2022 – Feb 21, 2022

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

luofei

author
#0 lore raw

PATCH v3 2/2 hw/poison: 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 | 11 +++++++++++
 1 file changed, 11 insertions(+)
mm/memory-failure.c +11 -0
index 59d6d939a752..17a7b0a94ab9 100644
@@ -1548,6 +1548,17 @@ 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);
+		if (flags & MF_MCE_HANDLE)
+			res = -EHWPOISON;
+		else
+			res = 0;
+		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
#1 lore raw
# please update "hw/poison" as well.
Quoted 6 lines · luofei

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.

Quoted 28 lines
---
 mm/memory-failure.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
mm/memory-failure.c +11 -0
index 59d6d939a752..17a7b0a94ab9 100644
@@ -1548,6 +1548,17 @@ 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);
+		if (flags & MF_MCE_HANDLE)
+			res = -EHWPOISON;
+		else
+			res = 0;
+		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