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.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Vlastimil Babka 2023-03-09 12:12:53 +01:00 committed by Andrew Morton
parent 183b7a60d3
commit 5cd70b96de

View file

@ -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);