On Fri, Aug 23, 2024 at 09:07:01PM GMT, Lorenzo Stoakes wrote: [snip] > void unlink_file_vma_batch_init(struct unlink_vma_file_batch *vb) > @@ -1426,9 +1536,10 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, > struct vm_area_struct *vma = *vmap; > unsigned long vma_start = vma->vm_start; > struct mm_struct *mm = vma->vm_mm; > - struct vm_area_struct *new_vma, *prev; > + struct vm_area_struct *new_vma; > bool faulted_in_anon_vma = true; > VMA_ITERATOR(vmi, mm, addr); > + VMG_VMA_STATE(vmg, &vmi, NULL, vma, addr, addr + len); > > /* > * If anonymous vma has not yet been faulted, update new pgoff > @@ -1439,11 +1550,18 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, > faulted_in_anon_vma = false; > } > > - new_vma = find_vma_prev(mm, addr, &prev); > + new_vma = find_vma_prev(mm, addr, &vmg.prev); > if (new_vma && new_vma->vm_start < addr + len) > return NULL; /* should never get here */ > > - new_vma = vma_merge_new_vma(&vmi, prev, vma, addr, addr + len, pgoff); > + vmg.vma = NULL; /* New VMA range. */ > + vmg.pgoff = pgoff; > + vmg.next = vma_next(&vmi); > + vma_prev(&vmi); > + vma_iter_next_range(&vmi); > + > + new_vma = vma_merge_new_range(&vmg); > + > if (new_vma) { > /* > * Source vma may have been merged into new_vma [snip] Hi Andrew - could you squash the attached fix-patch into this please? As there is an issue with a CONFIG_DEBUG_VM check firing when copy_vma() unnecessarily moves the VMA iterator as reported at [0]. Thanks! [0]: https://lore.kernel.org/linux-mm/202408271452.c842a71d-lkp@xxxxxxxxx/ ----8<----