mm: avoid rewalk in mmap_region
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 18 May 2023 14:55:44 +0000 (10:55 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 9 Jun 2023 23:25:35 +0000 (16:25 -0700)
If the iterator has moved to the previous entry, then step forward one
range, back to the gap.

Link: https://lkml.kernel.org/r/20230518145544.1722059-36-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: David Binderman <dcb314@hotmail.com>
Cc: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Vernon Yang <vernon2gm@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c

index 19d3c843be0c44f60defa97b92253e09f0ae99ff..44be7fdfaac9183e794c56d5e9d5f606afc8400c 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2606,6 +2606,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
        }
 
 cannot_expand:
+       if (prev)
+               vma_iter_next_range(&vmi);
+
        /*
         * Determine the object being mapped and call the appropriate
         * specific mapper. the address has already been validated, but