Re: [PATCH v2] mm/vma: don't remove VMA from rmap if pgoff unchanged

From: Lorenzo Stoakes (ARM)

Date: Fri Oct 02 2026 - 10:32:58 EST


On Fri, Oct 02, 2026 at 03:24:07PM +0100, Pedro Falcato wrote:
> On Wed, Sep 30, 2026 at 06:53:36PM +0100, Lorenzo Stoakes (ARM) wrote:
> > Suggested-by: Pan Deng <pan.deng@xxxxxxxxx>
> > Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>
> > Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
>
> Looks great, thanks!
>
> Reviewed-by: Pedro Falcato <pfalcato@xxxxxxx>

Thanks!

> > --- a/mm/vma.c
> > +++ b/mm/vma.c
> > @@ -201,8 +201,15 @@ static void init_multi_vma_prep(struct vma_prepare *vp,
> > if (vp->file)
> > vp->mapping = vma->vm_file->f_mapping;
> >
> > - if (vmg && vmg->skip_vma_uprobe)
> > + if (!vmg)
> > + return;
> > +
> > + if (vmg->skip_vma_uprobe)
> > vp->skip_vma_uprobe = true;
> > + if (vma_start_pgoff(vma) == vmg_start_pgoff(vmg))
> > + vp->file_pgoff_unchanged = true;
> > + if (vma_start_anon_pgoff(vma) == vmg_start_anon_pgoff(vmg))
> > + vp->anon_pgoff_unchanged = true;
>
> FWIW I kinda would've liked to abstract this out to rmap code, but a quick look
> shows that it is likely to become a header dependency hell if put in rmap.h. Could
> perhaps have been separated out to a function call.
>
> Anyway, your call :) This version already hides most of the ugly to
> interval tree code.

I'd rather keep it as-is. These case are explicitly setting the state because of
things known at that point, and as you say it's not possible to do it sensibly
due to headers etc.

--
Cheers, Lorenzo