]> Git Repo - linux.git/commitdiff
mm: memory: use nth_page() in clear/copy_subpage()
authorKefeng Wang <[email protected]>
Fri, 29 Dec 2023 08:22:07 +0000 (16:22 +0800)
committerAndrew Morton <[email protected]>
Thu, 22 Feb 2024 00:00:02 +0000 (16:00 -0800)
The clear and copy of huge gigantic page has converted to use nth_page()
to handle the possible discontinuous struct page(SPARSEMEM without
VMEMMAP), but not change for the non-gigantic part, fix it too.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kefeng Wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Zi Yan <[email protected]>
Cc: David Hildenbrand <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/memory.c

index 0bfc8b007c01a3323a15a17d51c4da46a6207540..a25bc8a370fd0e139440669d82dd5af22260b60a 100644 (file)
@@ -6163,7 +6163,7 @@ static int clear_subpage(unsigned long addr, int idx, void *arg)
 {
        struct page *page = arg;
 
-       clear_user_highpage(page + idx, addr);
+       clear_user_highpage(nth_page(page, idx), addr);
        return 0;
 }
 
@@ -6213,10 +6213,11 @@ struct copy_subpage_arg {
 static int copy_subpage(unsigned long addr, int idx, void *arg)
 {
        struct copy_subpage_arg *copy_arg = arg;
+       struct page *dst = nth_page(copy_arg->dst, idx);
+       struct page *src = nth_page(copy_arg->src, idx);
 
-       if (copy_mc_user_highpage(copy_arg->dst + idx, copy_arg->src + idx,
-                                 addr, copy_arg->vma)) {
-               memory_failure_queue(page_to_pfn(copy_arg->src + idx), 0);
+       if (copy_mc_user_highpage(dst, src, addr, copy_arg->vma)) {
+               memory_failure_queue(page_to_pfn(src), 0);
                return -EHWPOISON;
        }
        return 0;
This page took 0.063145 seconds and 4 git commands to generate.