Skip to contentSkip to conversation

mm: Remove src/dst mm parameter in copy_page_range()

PATCH Applied Peter Xu 3 participants 3 messages Oct 2, 2020 – Oct 5, 2020

Subsystems (4)
lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH v2 1/1 mm: Remove src/dst mm parameter in copy_page_range()

Both of the mm pointers are not needed after commit 7a4830c380f3 ("mm/fork:
Pass new vma pointer into copy_page_range()").

Jason Gunthorpe also reported that the ordering of copy_page_range() is odd. Since working at it, reorder the parameters to be logical, by (1) always put the dst_* fields to be before src_* fields, and (2) keep the same type of parameters together.

---
v2:
- further reorder some parameters and line format [Jason]

---
 include/linux/mm.h |   4 +-
 kernel/fork.c      |   2 +-
 mm/memory.c        | 139 ++++++++++++++++++++++++---------------------
 3 files changed, 76 insertions(+), 69 deletions(-)
include/linux/mm.h +2 -2
index 16b799a0522c..a26e9f706b25 100644
@@ -1645,8 +1645,8 @@ struct mmu_notifier_range;
 
 void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
 		unsigned long end, unsigned long floor, unsigned long ceiling);
-int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
-		    struct vm_area_struct *vma, struct vm_area_struct *new);
+int
+copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma);
 int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
 		   struct mmu_notifier_range *range,
 		   pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
kernel/fork.c +1 -1
index da8d360fb032..a7671f5cb3e1 100644
@@ -589,7 +589,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
 
 		mm->map_count++;
 		if (!(tmp->vm_flags & VM_WIPEONFORK))
-			retval = copy_page_range(mm, oldmm, mpnt, tmp);
+			retval = copy_page_range(tmp, mpnt);
 
 		if (tmp->vm_ops && tmp->vm_ops->open)
 			tmp->vm_ops->open(tmp);
mm/memory.c +73 -66

283 lines not on this page · raw message

Signature · 1 line
2.26.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 12 lines · Peter Xu

Both of the mm pointers are not needed after commit 7a4830c380f3 ("mm/fork:
Pass new vma pointer into copy_page_range()").

Jason Gunthorpe also reported that the ordering of copy_page_range() is odd. Since working at it, reorder the parameters to be logical, by (1) always put the dst_* fields to be before src_* fields, and (2) keep the same type of parameters together.

Quoted 8 lines

---
v2:
- further reorder some parameters and line format [Jason]

---
 include/linux/mm.h |   4 +-
 kernel/fork.c      |   2 +-
 mm/memory.c        | 139 ++++++++++++++++++++++++---------------------
 3 files changed, 76 insertions(+), 69 deletions(-)

Thanks, looks more readable to me

Jason

Acked-by on v2 1/1
#2 lore raw
In reply to Peter Xu
Quoted 8 lines · Peter Xu

Both of the mm pointers are not needed after commit 7a4830c380f3 ("mm/fork:
Pass new vma pointer into copy_page_range()").

Jason Gunthorpe also reported that the ordering of copy_page_range() is odd. Since working at it, reorder the parameters to be logical, by (1) always put the dst_* fields to be before src_* fields, and (2) keep the same type of parameters together.

Quoted 4 lines
Signature · 1 line
 Kirill A. Shutemov