Commit 5cd70b96 authored by Vlastimil Babka's avatar Vlastimil Babka Committed by Andrew Morton

mm/mmap/vma_merge: initialize mid and next in natural order

It is more intuitive to go from prev to mid and then next.  No functional
change.

Link: https://lkml.kernel.org/r/20230309111258.24079-6-vbabka@suse.czSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
Reviewed-by: default avatarLorenzo Stoakes <lstoakes@gmail.com>
Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 183b7a60
......@@ -912,10 +912,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm,
if (vm_flags & VM_SPECIAL)
return NULL;
next = find_vma(mm, prev ? prev->vm_end : 0);
mid = next;
if (next && next->vm_end == end) /* cases 6, 7, 8 */
next = find_vma(mm, next->vm_end);
mid = find_vma(mm, prev ? prev->vm_end : 0);
if (mid && mid->vm_end == end) /* cases 6, 7, 8 */
next = find_vma(mm, mid->vm_end);
else
next = mid;
/* verify some invariant that must be enforced by the caller */
VM_WARN_ON(prev && addr <= prev->vm_start);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment