diff options
author | Vlastimil Babka <vbabka@suse.cz> | 2023-03-09 12:12:53 +0100 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-04-05 19:42:49 -0700 |
commit | 5cd70b96debbce9182e903cc6f4ed261ae55fa8b (patch) | |
tree | fd2e05af2d2ed3eb0bb6a05176b5cef33afd35fc /mm | |
parent | 183b7a60d349abeb3067867c8bdbdd6e0d3b7d86 (diff) |
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index 8394901c35b4..d3765dcd9a15 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -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); |