From: Jiaqi Yan <jiaqiyan@google.com>
To: kirill.shutemov@linux.intel.com, kirill@shutemov.name,
shy828301@gmail.com, tongtiangen@huawei.com,
tony.luck@intel.com, akpm@linux-foundation.org
Cc: naoya.horiguchi@nec.com, linmiaohe@huawei.com,
jiaqiyan@google.com, linux-mm@kvack.org, osalvador@suse.de,
wangkefeng.wang@huawei.com
Subject: [PATCH v10 2/3] mm/hwpoison: introduce copy_mc_highpage
Date: Sat, 4 Mar 2023 22:51:11 -0800 [thread overview]
Message-ID: <20230305065112.1932255-3-jiaqiyan@google.com> (raw)
In-Reply-To: <20230305065112.1932255-1-jiaqiyan@google.com>
Similar to how copy_mc_user_highpage is implemented for
copy_user_highpage on #MC supported architecture, introduce
the #MC handled version of copy_highpage.
This helper has immediate usage when khugepaged wants to copy
file-backed memory pages and tolerate #MC.
Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
---
include/linux/highmem.h | 54 +++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 13 deletions(-)
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 1128b7114931f..7cbecae39b3eb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -315,7 +315,29 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
#endif
+#ifndef __HAVE_ARCH_COPY_HIGHPAGE
+
+static inline void copy_highpage(struct page *to, struct page *from)
+{
+ char *vfrom, *vto;
+
+ vfrom = kmap_local_page(from);
+ vto = kmap_local_page(to);
+ copy_page(vto, vfrom);
+ kmsan_copy_page_meta(to, from);
+ kunmap_local(vto);
+ kunmap_local(vfrom);
+}
+
+#endif
+
#ifdef copy_mc_to_kernel
+/*
+ * If architecture supports machine check exception handling, define the
+ * #MC versions of copy_user_highpage and copy_highpage. They copy a memory
+ * page with #MC in source page (@from) handled, and return the number
+ * of bytes not copied if there was a #MC, otherwise 0 for success.
+ */
static inline int copy_mc_user_highpage(struct page *to, struct page *from,
unsigned long vaddr, struct vm_area_struct *vma)
{
@@ -332,29 +354,35 @@ static inline int copy_mc_user_highpage(struct page *to, struct page *from,
return ret;
}
-#else
-static inline int copy_mc_user_highpage(struct page *to, struct page *from,
- unsigned long vaddr, struct vm_area_struct *vma)
-{
- copy_user_highpage(to, from, vaddr, vma);
- return 0;
-}
-#endif
-#ifndef __HAVE_ARCH_COPY_HIGHPAGE
-
-static inline void copy_highpage(struct page *to, struct page *from)
+static inline int copy_mc_highpage(struct page *to, struct page *from)
{
+ unsigned long ret;
char *vfrom, *vto;
vfrom = kmap_local_page(from);
vto = kmap_local_page(to);
- copy_page(vto, vfrom);
- kmsan_copy_page_meta(to, from);
+ ret = copy_mc_to_kernel(vto, vfrom, PAGE_SIZE);
+ if (!ret)
+ kmsan_copy_page_meta(to, from);
kunmap_local(vto);
kunmap_local(vfrom);
+
+ return ret;
+}
+#else
+static inline int copy_mc_user_highpage(struct page *to, struct page *from,
+ unsigned long vaddr, struct vm_area_struct *vma)
+{
+ copy_user_highpage(to, from, vaddr, vma);
+ return 0;
}
+static inline int copy_mc_highpage(struct page *to, struct page *from)
+{
+ copy_highpage(to, from);
+ return 0;
+}
#endif
static inline void memcpy_page(struct page *dst_page, size_t dst_off,
--
2.40.0.rc0.216.gc4246ad0f0-goog
next prev parent reply other threads:[~2023-03-05 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-05 6:51 [PATCH v10 0/3] Memory poison recovery in khugepaged collapsing Jiaqi Yan
2023-03-05 6:51 ` [PATCH v10 1/3] mm/khugepaged: recover from poisoned anonymous memory Jiaqi Yan
2023-03-20 14:42 ` Jiaqi Yan
2023-03-21 0:12 ` Yang Shi
2023-03-23 21:37 ` Yang Shi
2023-03-24 15:34 ` Jiaqi Yan
2023-03-24 20:11 ` Yang Shi
2023-03-24 22:31 ` Jiaqi Yan
2023-03-27 20:46 ` Jiaqi Yan
2023-03-05 6:51 ` Jiaqi Yan [this message]
2023-03-05 6:56 ` [PATCH v10 2/3] mm/hwpoison: introduce copy_mc_highpage Jiaqi Yan
2023-03-24 20:24 ` Yang Shi
2023-03-05 6:51 ` [PATCH v10 3/3] mm/khugepaged: recover from poisoned file-backed memory Jiaqi Yan
2023-03-24 21:15 ` Yang Shi
2023-03-24 22:54 ` Jiaqi Yan
2023-03-25 0:39 ` Hugh Dickins
2023-03-27 21:15 ` 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=20230305065112.1932255-3-jiaqiyan@google.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 \
--cc=wangkefeng.wang@huawei.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;
as well as URLs for NNTP newsgroup(s).