From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, Jane Chu <jane.chu@oracle.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Tony Luck <tony.luck@intel.com>, Jiaqi Yan <jiaqiyan@google.com>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH 2/2] mm: support poison recovery from copy_present_page()
Date: Tue, 10 Sep 2024 14:35:18 +0800 [thread overview]
Message-ID: <7318807d-ee77-48e3-a827-39cbb44b3506@huawei.com> (raw)
In-Reply-To: <635585c1-5d51-6a23-70ad-560e164068f6@huawei.com>
On 2024/9/10 10:19, Miaohe Lin wrote:
> On 2024/9/6 10:42, Kefeng Wang wrote:
>> Similar to other poison recovery, use copy_mc_user_highpage() to
>> avoid potentially kernel panic during copy page in copy_present_page()
>> from fork, once copy failed due to hwpoison in source page, we need
>> to break out of copy in copy_pte_range() and release prealloc folio,
>> so copy_mc_user_highpage() is moved ahead before set *prealloc to NULL.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> mm/memory.c | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/memory.c b/mm/memory.c
>> index d310c073a1b3..6e7b78e49d1a 100644
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -926,8 +926,11 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
>> * We have a prealloc page, all good! Take it
>> * over and copy the page & arm it.
>> */
>> +
>> + if (copy_mc_user_highpage(&new_folio->page, page, addr, src_vma))
>> + return -EHWPOISON;
>> +
>> *prealloc = NULL;
>> - copy_user_highpage(&new_folio->page, page, addr, src_vma);
>> __folio_mark_uptodate(new_folio);
>> folio_add_new_anon_rmap(new_folio, dst_vma, addr, RMAP_EXCLUSIVE);
>> folio_add_lru_vma(new_folio, dst_vma);
>> @@ -1166,8 +1169,9 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
>> /*
>> * If we need a pre-allocated page for this pte, drop the
>> * locks, allocate, and try again.
>> + * If copy failed due to hwpoison in source page, break out.
>> */
>> - if (unlikely(ret == -EAGAIN))
>> + if (unlikely(ret == -EAGAIN || ret == -EHWPOISON))
>
> Will it be better to put checking ret against -EHWPOISON in a new line? -EAGAIN case will enter the
> loop again but -EHWPOISON case never does.
Maybe not a newline since we will recheck the ret in the below and
return directly from copy_present_page().
>
>> break;
>> if (unlikely(prealloc)) {
>> /*
>> @@ -1197,7 +1201,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
>> goto out;
>> }
>> entry.val = 0;
>> - } else if (ret == -EBUSY) {
>> + } else if (ret == -EBUSY || unlikely(ret == -EHWPOISON)) {
>
> The caller of copy_pte_range() always set errno to -ENOMEM. So fork will failed with ENOMEM even if the real
> cause is failed to copy due to hwpoison in source page. It's a pity.
Yes, it's not just the new -EHWPOISON, all other errnos(ENOENT/EIO) will
be ignored and return -ENOMEM instead.
>
> Thanks.
> .
next prev parent reply other threads:[~2024-09-10 6:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 2:41 [PATCH 0/2] mm: hwpoison: two more poison recovery Kefeng Wang
2024-09-06 2:42 ` [PATCH 1/2] mm: support poison recovery from do_cow_fault() Kefeng Wang
2024-09-06 22:17 ` jane.chu
2024-09-10 1:58 ` Miaohe Lin
2024-09-10 2:13 ` Kefeng Wang
2024-09-10 2:15 ` [PATCH] mm: support poison recovery from do_cow_fault() fix Kefeng Wang
2024-09-12 2:03 ` Miaohe Lin
2024-09-06 2:42 ` [PATCH 2/2] mm: support poison recovery from copy_present_page() Kefeng Wang
2024-09-06 23:14 ` jane.chu
2024-09-10 2:19 ` Miaohe Lin
2024-09-10 6:35 ` Kefeng Wang [this message]
2024-09-12 2:06 ` Miaohe Lin
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=7318807d-ee77-48e3-a827-39cbb44b3506@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jane.chu@oracle.com \
--cc=jiaqiyan@google.com \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=nao.horiguchi@gmail.com \
--cc=tony.luck@intel.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