Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/fork: Pass new vma pointer into copy_page_range()

This prepares for the future work to trigger early cow on pinned pages
during fork().

No functional change intended.

Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Peter Xu and committed by
Linus Torvalds
7a4830c3 008cfe44

+11 -7
+1 -1
include/linux/mm.h
··· 1646 1646 void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, 1647 1647 unsigned long end, unsigned long floor, unsigned long ceiling); 1648 1648 int copy_page_range(struct mm_struct *dst, struct mm_struct *src, 1649 - struct vm_area_struct *vma); 1649 + struct vm_area_struct *vma, struct vm_area_struct *new); 1650 1650 int follow_pte_pmd(struct mm_struct *mm, unsigned long address, 1651 1651 struct mmu_notifier_range *range, 1652 1652 pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
+1 -1
kernel/fork.c
··· 589 589 590 590 mm->map_count++; 591 591 if (!(tmp->vm_flags & VM_WIPEONFORK)) 592 - retval = copy_page_range(mm, oldmm, mpnt); 592 + retval = copy_page_range(mm, oldmm, mpnt, tmp); 593 593 594 594 if (tmp->vm_ops && tmp->vm_ops->open) 595 595 tmp->vm_ops->open(tmp);
+9 -5
mm/memory.c
··· 819 819 820 820 static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, 821 821 pmd_t *dst_pmd, pmd_t *src_pmd, struct vm_area_struct *vma, 822 + struct vm_area_struct *new, 822 823 unsigned long addr, unsigned long end) 823 824 { 824 825 pte_t *orig_src_pte, *orig_dst_pte; ··· 890 889 891 890 static inline int copy_pmd_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, 892 891 pud_t *dst_pud, pud_t *src_pud, struct vm_area_struct *vma, 892 + struct vm_area_struct *new, 893 893 unsigned long addr, unsigned long end) 894 894 { 895 895 pmd_t *src_pmd, *dst_pmd; ··· 917 915 if (pmd_none_or_clear_bad(src_pmd)) 918 916 continue; 919 917 if (copy_pte_range(dst_mm, src_mm, dst_pmd, src_pmd, 920 - vma, addr, next)) 918 + vma, new, addr, next)) 921 919 return -ENOMEM; 922 920 } while (dst_pmd++, src_pmd++, addr = next, addr != end); 923 921 return 0; ··· 925 923 926 924 static inline int copy_pud_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, 927 925 p4d_t *dst_p4d, p4d_t *src_p4d, struct vm_area_struct *vma, 926 + struct vm_area_struct *new, 928 927 unsigned long addr, unsigned long end) 929 928 { 930 929 pud_t *src_pud, *dst_pud; ··· 952 949 if (pud_none_or_clear_bad(src_pud)) 953 950 continue; 954 951 if (copy_pmd_range(dst_mm, src_mm, dst_pud, src_pud, 955 - vma, addr, next)) 952 + vma, new, addr, next)) 956 953 return -ENOMEM; 957 954 } while (dst_pud++, src_pud++, addr = next, addr != end); 958 955 return 0; ··· 960 957 961 958 static inline int copy_p4d_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, 962 959 pgd_t *dst_pgd, pgd_t *src_pgd, struct vm_area_struct *vma, 960 + struct vm_area_struct *new, 963 961 unsigned long addr, unsigned long end) 964 962 { 965 963 p4d_t *src_p4d, *dst_p4d; ··· 975 971 if (p4d_none_or_clear_bad(src_p4d)) 976 972 continue; 977 973 if (copy_pud_range(dst_mm, src_mm, dst_p4d, src_p4d, 978 - vma, addr, next)) 974 + vma, new, addr, next)) 979 975 return -ENOMEM; 980 976 } while (dst_p4d++, src_p4d++, addr = next, addr != end); 981 977 return 0; 982 978 } 983 979 984 980 int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, 985 - struct vm_area_struct *vma) 981 + struct vm_area_struct *vma, struct vm_area_struct *new) 986 982 { 987 983 pgd_t *src_pgd, *dst_pgd; 988 984 unsigned long next; ··· 1037 1033 if (pgd_none_or_clear_bad(src_pgd)) 1038 1034 continue; 1039 1035 if (unlikely(copy_p4d_range(dst_mm, src_mm, dst_pgd, src_pgd, 1040 - vma, addr, next))) { 1036 + vma, new, addr, next))) { 1041 1037 ret = -ENOMEM; 1042 1038 break; 1043 1039 }