From: Kaitao Cheng <kaitao.cheng@linux.dev>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
"Huang, Ying" <ying.huang@linux.alibaba.com>,
Yuanhe Shu <xiangzao@linux.alibaba.com>
Cc: akpm@linux-foundation.org, vbabka@kernel.org,
linmiaohe@huawei.com, nao.horiguchi@gmail.com, ziy@nvidia.com,
wangkefeng.wang@huawei.com, tujinjiang@huawei.com,
mgorman@techsingularity.net, chengkaitao@kylinos.cn,
muchun.song@linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm/compaction: skip folios containing hwpoisoned pages
Date: Thu, 22 Oct 2026 20:38:53 +0800 [thread overview]
Message-ID: <58cfeba3-a3c0-426e-ba97-8f82da5b1e8d@linux.dev> (raw)
In-Reply-To: <e4c3ce3a-c19b-418a-a92e-40e077f1ea63@kernel.org>
在 2026/10/21 16:27, David Hildenbrand (Arm) 写道:
> On 10/21/26 04:49, Kaitao Cheng wrote:
>>
>>
>> 在 2026/10/20 21:58, David Hildenbrand (Arm) 写道:
>>> On 10/20/26 15:31, Kaitao Cheng wrote:
>>>>
>>>>
>>>> 在 2026/10/20 21:07, David Hildenbrand (Arm) 写道:
>>>>
>>>> It does require architecture support, but that doesn't seem practical, haha.
>>>
>>> Well, but that's required when an arch wants to rule out all races.
>>>
>>>>> Will architectures that are not prepared for copy_mc_user_highpage() not simply
>>>>> crash if they trigger an MCE during an access?
After thinking about it, if the memcpy here is guaranteed to cause a crash,
wouldn't the system inevitably crash at some point anyway, even if we check
folio_contain_hwpoisoned_page() beforehand and return early, since this kind
of memory error is unrecoverable?
If the system won't crash, it seems fine to defer the check as well.
>>>>
>>>> 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.
>>>>
>>>
>>> I don't see how checking after the copy makes any sense? :)
>>>
>>> You already crashed if there was a problem, why check? Or what am I missing?
>> In cases such as transient errors, software poison injection, repeated
>> bit flips in memory, or bit flips in the ECC check bits themselves, a
>> page may be faulty while memcpy() still completes normally. If the copied
>> data is correct, only the PG_hwpoison flag is lost during migration. But
>> if the copied data is corrupted and the kernel or a process subsequently
>> treats it as valid, I think the consequences could be more serious than
>> an immediate crash. However, I cannot estimate how likely this is to happen.
> That's the point, me neither. I'm happy to perform checks before access, or
> after, in the default copy implementation, but I want to have properly
> documented how this makes sense and which races exist.
>
Here are a few subtle corner cases I came up with. They may be extremely
unlikely to occur.
case A:
CPU 1 CPU 2
if (folio_contain_hwpoisoned_page()) The check passes because
return -EHWPOISON; PG_hwpoisoned is not set.
A transient bus error occurs,
or the flag is injected by software.
PG_hwpoisoned is set.
The bus temporarily returns to normal.
memcpy(new, old); The copy succeeds and copies
the correct data.
PG_hwpoisoned is not propagated
to the new page, so the flag is lost.
case B:
CPU 1 CPU 2
if (folio_contain_hwpoisoned_page())
return -EHWPOISON;
A memory bit flips, causing
an ECC error.
PG_hwpoisoned is set.
Other bits in the same byte then flip,
or the ECC check bits themselves flip.
ECC check passes.
memcpy(new, old); The copy succeeds but copies
corrupted data.
PG_hwpoisoned is lost.
The kernel or user treats
the corrupted data as valid.
--
Thanks
Kaitao Cheng
next prev parent reply other threads:[~2026-10-22 12:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 10:58 [PATCH 0/2] mm: don't migrate " Yuanhe Shu
2026-09-28 10:58 ` [PATCH 1/2] mm/compaction: skip " Yuanhe Shu
2026-09-28 12:12 ` David Hildenbrand (Arm)
2026-09-29 3:41 ` Yuanhe Shu
2026-10-11 13:14 ` Huang, Ying
2026-10-20 7:16 ` Yuanhe Shu
2026-10-20 7:52 ` David Hildenbrand (Arm)
2026-10-20 11:27 ` Kaitao Cheng
2026-10-20 13:07 ` David Hildenbrand (Arm)
2026-10-20 13:31 ` Kaitao Cheng
2026-10-20 13:58 ` David Hildenbrand (Arm)
2026-10-21 2:49 ` Kaitao Cheng
2026-10-21 8:27 ` David Hildenbrand (Arm)
2026-10-22 12:38 ` Kaitao Cheng [this message]
2026-10-10 8:35 ` Kaitao Cheng
2026-09-28 10:58 ` [PATCH 2/2] mm/migrate: refuse to migrate " Yuanhe Shu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58cfeba3-a3c0-426e-ba97-8f82da5b1e8d@linux.dev \
--to=kaitao.cheng@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=chengkaitao@kylinos.cn \
--cc=david@kernel.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=tujinjiang@huawei.com \
--cc=vbabka@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=xiangzao@linux.alibaba.com \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®