Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a247c3a9 authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds
Browse files

rmap: fix walk during fork



The below bug in fork led to the rmap walk finding the parent huge-pmd
twice instead of just once, because the anon_vma_chain objects of the
child vma still point to the vma->vm_mm of the parent.

The patch fixes it by making the rmap walk accurate during fork.  It's not
a big deal normally but it worth being accurate considering the cost is
the same.

Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Acked-by: default avatarJohannes Weiner <jweiner@redhat.com>
Acked-by: default avatarRik van Riel <riel@redhat.com>
Acked-by: default avatarHugh Dickins <hughd@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent df08cdc7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -356,10 +356,10 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
		if (IS_ERR(pol))
		if (IS_ERR(pol))
			goto fail_nomem_policy;
			goto fail_nomem_policy;
		vma_set_policy(tmp, pol);
		vma_set_policy(tmp, pol);
		tmp->vm_mm = mm;
		if (anon_vma_fork(tmp, mpnt))
		if (anon_vma_fork(tmp, mpnt))
			goto fail_nomem_anon_vma_fork;
			goto fail_nomem_anon_vma_fork;
		tmp->vm_flags &= ~VM_LOCKED;
		tmp->vm_flags &= ~VM_LOCKED;
		tmp->vm_mm = mm;
		tmp->vm_next = tmp->vm_prev = NULL;
		tmp->vm_next = tmp->vm_prev = NULL;
		file = tmp->vm_file;
		file = tmp->vm_file;
		if (file) {
		if (file) {