Re: [PATCH v2] mm/migrate: Avoid copying hwpoisoned folios during migration

From: Huang, Ying

Date: Tue Jul 07 2026 - 07:09:33 EST


"David Hildenbrand (Arm)" <david@xxxxxxxxxx> writes:

> On 7/7/26 11:01, Kaitao Cheng wrote:
>> From: Kaitao Cheng <chengkaitao@xxxxxxxxxx>
>>
>> The generic folio migration path can copy the source folio after it has
>> been unmapped. For normal and THP folios this goes through
>> move_to_new_folio(), then the filesystem or anonymous migration callback,
>> and commonly reaches folio_mc_copy().
>>
>> folio_mc_copy() uses copy_mc_highpage(), but architectures without
>> copy_mc_to_kernel support fall back to copy_highpage(). If the source
>> folio already contains a hwpoisoned page, a normal copy can consume the
>> poisoned memory and trigger a synchronous machine check.
>
> Well, but the code can still race with memory_failure() IIUC, so it's not really
> safe either?

Yes. So the better way to fix this is to implement copy_mc_to_kernel()
for the target architectures, or to implement the trick in the fallback?

---
Best Regards,
Huang, Ying