Re: [PATCH -next v2] mm: hwposion: support recovery from ksm_might_need_to_copy()

From: Kefeng Wang
Date: Mon Dec 12 2022 - 06:44:17 EST



On 2022/12/12 10:36, Miaohe Lin wrote:
On 2022/12/9 15:28, Kefeng Wang wrote:
When the kernel copy a page from ksm_might_need_to_copy(), but runs
into an uncorrectable error, it will crash since poisoned page is
consumed by kernel, this is similar to Copy-on-write poison recovery,
When an error is detected during the page copy, return VM_FAULT_HWPOISON,
which help us to avoid system crash. Note, memory failure on a KSM
page will be skipped, but still call memory_failure_queue() to be
consistent with general memory failure process.
...
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 908a529bca12..d479811bc311 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1767,7 +1767,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
swapcache = page;
page = ksm_might_need_to_copy(page, vma, addr);
- if (unlikely(!page))
+ if (IS_ERR_OR_NULL(page))
IMHO, it might be better to install a hwpoison entry here. Or later swapoff ops will trigger
the uncorrectable error again?
Thanks for you suggestion, will do in v3.
Thanks,
Miaohe Lin