From: Jiaqi Yan <jiaqiyan@google.com>
To: "Luck, Tony" <tony.luck@intel.com>,
"shy828301@gmail.com" <shy828301@gmail.com>
Cc: "kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"kirill@shutemov.name" <kirill@shutemov.name>,
"tongtiangen@huawei.com" <tongtiangen@huawei.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"naoya.horiguchi@nec.com" <naoya.horiguchi@nec.com>,
"linmiaohe@huawei.com" <linmiaohe@huawei.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"osalvador@suse.de" <osalvador@suse.de>
Subject: Re: [PATCH v7 1/2] mm/khugepaged: recover from poisoned anonymous memory
Date: Fri, 18 Nov 2022 11:38:22 -0800 [thread overview]
Message-ID: <CACw3F50i8YMntsOpimZZwthE3F6Ft1uhT-2ybXOfA+p2k0wPhQ@mail.gmail.com> (raw)
In-Reply-To: <SJ1PR11MB6083A2F99BC138061F50BFC8FC099@SJ1PR11MB6083.namprd11.prod.outlook.com>
On Fri, Nov 18, 2022 at 8:46 AM Luck, Tony <tony.luck@intel.com> wrote:
>
> +/*
> + * Machine check exception handled version of copy_highpage.
> + * Return true if copying page content failed; otherwise false.
> + * Note handling #MC requires arch opt-in.
> + */
> +static inline bool copy_highpage_mc(struct page *to, struct page *from)
> +{
> + char *vfrom, *vto;
> + unsigned long ret;
> +
> + vfrom = kmap_local_page(from);
> + vto = kmap_local_page(to);
> + ret = copy_mc_to_kernel(vto, vfrom, PAGE_SIZE);
> + kunmap_local(vto);
> + kunmap_local(vfrom);
> +
> + return ret > 0;
> +}
>
> Andrew Morton took my patches to recover from copy-on-write faults
> into the -mm tree. They are now sitting in linux-next (hopefully) ready
> for the next merge window.
>
> I had copied this function from an earlier version of your patch, but
> there was a suggestion that copy_mc_user_highpage() would be a
> more consistent name with other copy code that can handle machine
> checks. There was also an upstream change to copy_highpage()
> that needed to be reflected here.
Thanks for pointing this out, Tony. Is it the kmsan_copy_page_meta(to,
from) call in copy_highpage()? I will make sure to include it in
copy_highpage_mc(). If there is more, can you provide lore pointers?
>
> Net result, this version is already in flight:
>
> static inline int copy_mc_user_highpage(struct page *to, struct page *from,
> unsigned long vaddr, struct vm_area_struct *vma)
> {
> unsigned long ret;
> char *vfrom, *vto;
>
> vfrom = kmap_local_page(from);
> vto = kmap_local_page(to);
> ret = copy_mc_to_kernel(vto, vfrom, PAGE_SIZE);
> if (!ret)
> kmsan_unpoison_memory(page_address(to), PAGE_SIZE);
Does it make sense to kmsan_unpoison_memory in copy_highpage? (and in
copy_mc_highpage if no MC happens?)
> kunmap_local(vto);
> kunmap_local(vfrom);
>
> return ret;
> }
>
> -Tony
While I am ok to switch to copy_mc_user_highpage for this commit
(given __collapse_huge_page_copy originally uses copy_user_highpage),
the question is, Yang Shi suggested in a previous version to unify the
copy routine used by both __collapse_huge_page_copy (using
copy_user_highpage) and collapse_file (using copy_highpage). I prefer
MC-aware copy_highpage because collapse_file may have a hard time to
adapt to the vaddr and vma in copy_user_highpage's interface, and
neither collapse_file nor __collapse_huge_page_copy gain anything from
passing vaddr and vma (correct me if I am wrong).
So I would still prefer copy_mc_highpage (after renaming and adding
kmsan_xxx calls) to be used by both __collapse_huge_page_copy and
collapse_file. What are your opinions, Tony and Yang?
next prev parent reply other threads:[~2022-11-18 19:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 1:31 [PATCH v7 0/2] Memory poison recovery in khugepaged collapsing Jiaqi Yan
2022-11-18 1:31 ` [PATCH v7 1/2] mm/khugepaged: recover from poisoned anonymous memory Jiaqi Yan
2022-11-18 16:46 ` Luck, Tony
2022-11-18 19:38 ` Jiaqi Yan [this message]
2022-11-18 22:18 ` Andrew Morton
2022-11-18 1:31 ` [PATCH v7 2/2] mm/khugepaged: recover from poisoned file-backed memory Jiaqi Yan
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=CACw3F50i8YMntsOpimZZwthE3F6Ft1uhT-2ybXOfA+p2k0wPhQ@mail.gmail.com \
--to=jiaqiyan@google.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=osalvador@suse.de \
--cc=shy828301@gmail.com \
--cc=tongtiangen@huawei.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