Skip to content

Commit

Permalink
mm: vma_adjust: remove superfluous confusing update in remove_next ==…
Browse files Browse the repository at this point in the history
… 1 case

mm->highest_vm_end doesn't need any update.

After finally removing the oddness from vma_merge case 8 that was
causing:

1) constant risk of trouble whenever anybody would check vma fields
   from rmap_walks, like it happened when page migration was
   introduced and it read the vma->vm_page_prot from a rmap_walk

2) the callers of vma_merge to re-initialize any value different from
   the current vma, instead of vma_merge() more reliably returning a
   vma that already matches all fields passed as parameter

.. it is also worth to take the opportunity of cleaning up superfluous
code in vma_adjust(), that if not removed adds up to the hard
readability of the function.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andrea Arcangeli <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Jan Vorlicek <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
aagit authored and torvalds committed Oct 8, 2016
1 parent 6d2329f commit fb8c41e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,28 @@ int vma_adjust(struct vm_area_struct *vma, unsigned long start,
}
else if (next)
vma_gap_update(next);
else
mm->highest_vm_end = end;
else {
/*
* If remove_next == 2 we obviously can't
* reach this path.
*
* If remove_next == 3 we can't reach this
* path because pre-swap() next is always not
* NULL. pre-swap() "next" is not being
* removed and its next->vm_end is not altered
* (and furthermore "end" already matches
* next->vm_end in remove_next == 3).
*
* We reach this only in the remove_next == 1
* case if the "next" vma that was removed was
* the highest vma of the mm. However in such
* case next->vm_end == "end" and the extended
* "vma" has vma->vm_end == next->vm_end so
* mm->highest_vm_end doesn't need any update
* in remove_next == 1 case.
*/
VM_WARN_ON(mm->highest_vm_end != end);
}
}
if (insert && file)
uprobe_mmap(insert);
Expand Down

0 comments on commit fb8c41e

Please sign in to comment.