Re: [PATCH 1/2] mm/compaction: skip folios containing hwpoisoned pages
From: Kaitao Cheng
Date: Tue Oct 20 2026 - 10:07:54 EST
在 2026/10/20 21:07, David Hildenbrand (Arm) 写道:
> On 10/20/26 13:27, Kaitao Cheng wrote:
>>
>>
>> 在 2026/10/11 21:14, Huang, Ying 写道:
>>> Yuanhe Shu <xiangzao@xxxxxxxxxxxxxxxxx> writes:
>>>
>>>>
>>>> Agreed, and nothing here replaces copy_mc. Two things the check adds
>>>> while that work is pending: on archs without copy_mc the plain copy
>>>> does not fail, it consumes the poison - the same poison consumption
>>>> commit 841a8bfcbad9 ("mm: prevent poison consumption when splitting
>>>> THP") refused to risk on the split path, at your suggestion; and the
>>>> refusal happens before the copy is attempted at all, while copy_mc
>>>> recovers only during the read. The check and copy_mc compose.
>>>>
>>>
>>> Is it good to implement the trick in copy_mc_user_highpage() and
>>> copy_mc_highpage() if the macro copy_mc_to_kernel is undefined?
>>
>> On architectures with hardware error correction and exception recovery
>> support, accessing faulty memory automatically triggers an exception,
>> which itself guarantees atomicity.
>>
>> On architectures without such support, even if we implement this logic
>> in copy_mc_user_highpage() and copy_mc_highpage(), checking the hwpoison
>> flag and copying the data remain two separate operations. They cannot
>> be performed atomically, so there is still a race window between them,
>> however small.
>
> Yes. And you need proper architecture support to fix it?
It does require architecture support, but that doesn't seem practical, haha.
>> Moving the hwpoison check after the copy might address this issue.
>> Is there anything wrong with my understanding?
>
> Will architectures that are not prepared for copy_mc_user_highpage() not simply
> crash if they trigger an MCE during an access?
>
Do we need to check both before and after the copy? This feels a bit
redundant, and I'm not sure whether such a small race window warrants
an additional check.
--
Thanks
Kaitao Cheng