2022-10-21 16:40:49

by James Houghton

[permalink] [raw]
Subject: [RFC PATCH v2 30/47] hugetlb: add high-granularity check for hwpoison in fault path

Because hwpoison swap entries may be placed beneath the hstate-level
PTE, we need to check for it separately (on top of the hstate-level PTE
check that remains).

Signed-off-by: James Houghton <[email protected]>
---
mm/hugetlb.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8dba8d59ebe5..bb0005d57cab 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -6154,6 +6154,11 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
migration_entry_wait_huge(vma, &hpte);
return 0;
+ } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) {
+ hugetlb_vma_unlock_read(vma);
+ mutex_unlock(&hugetlb_fault_mutex_table[hash]);
+ return VM_FAULT_HWPOISON_LARGE |
+ VM_FAULT_SET_HINDEX(hstate_index(h));
}

/* PTE markers should be handled the same way as none pte */
--
2.38.0.135.g90850a2211-goog