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

[PATCH] mm: dup_mmap use oldmm more

Use the parent's oldmm throughout dup_mmap, instead of perversely going back
to current->mm. (Can you hear the sigh of relief from those mpnts? Usually I
squash them, but not today.)

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
fd3e42fc ae859762

+6 -6
+6 -6
kernel/fork.c
··· 182 182 } 183 183 184 184 #ifdef CONFIG_MMU 185 - static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm) 185 + static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) 186 186 { 187 - struct vm_area_struct * mpnt, *tmp, **pprev; 187 + struct vm_area_struct *mpnt, *tmp, **pprev; 188 188 struct rb_node **rb_link, *rb_parent; 189 189 int retval; 190 190 unsigned long charge; 191 191 struct mempolicy *pol; 192 192 193 193 down_write(&oldmm->mmap_sem); 194 - flush_cache_mm(current->mm); 194 + flush_cache_mm(oldmm); 195 195 mm->locked_vm = 0; 196 196 mm->mmap = NULL; 197 197 mm->mmap_cache = NULL; ··· 204 204 rb_parent = NULL; 205 205 pprev = &mm->mmap; 206 206 207 - for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) { 207 + for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) { 208 208 struct file *file; 209 209 210 210 if (mpnt->vm_flags & VM_DONTCOPY) { ··· 265 265 rb_parent = &tmp->vm_rb; 266 266 267 267 mm->map_count++; 268 - retval = copy_page_range(mm, current->mm, tmp); 268 + retval = copy_page_range(mm, oldmm, tmp); 269 269 spin_unlock(&mm->page_table_lock); 270 270 271 271 if (tmp->vm_ops && tmp->vm_ops->open) ··· 277 277 retval = 0; 278 278 279 279 out: 280 - flush_tlb_mm(current->mm); 280 + flush_tlb_mm(oldmm); 281 281 up_write(&oldmm->mmap_sem); 282 282 return retval; 283 283 fail_nomem_policy: