[29/43] mm: Remove unnecessary write to vma iterator in __vma_adjust()

Message ID 20221129164352.3374638-30-Liam.Howlett@oracle.com
State New
Headers
Series VMA type safety through VMA iterator |

Commit Message

Liam R. Howlett Nov. 29, 2022, 4:44 p.m. UTC
  From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

If the vma start address is going to change due to an insert, then it is
safe to not write the vma to the tree.  The write of the insert vma will
alter the tree as necessary.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/mmap.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Patch

diff --git a/mm/mmap.c b/mm/mmap.c
index 8db711622d50..f37a6b5a40d6 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -779,10 +779,12 @@  int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma,
 	}
 
 	if (start != vma->vm_start) {
-		if ((vma->vm_start < start) &&
-		    (!insert || (insert->vm_end != start))) {
-			vma_iter_clear(vmi, vma->vm_start, start);
-			VM_WARN_ON(insert && insert->vm_start > vma->vm_start);
+		if (vma->vm_start < start) {
+			if (!insert || (insert->vm_end != start)) {
+				vma_iter_clear(vmi, vma->vm_start, start);
+				vma_iter_set(vmi, start);
+				VM_WARN_ON(insert && insert->vm_start > vma->vm_start);
+			}
 		} else {
 			vma_changed = true;
 		}