Re: [PATCH 7/8] mm/rmap: allocate anon_vma_chain objects unlocked when possible

From: Lorenzo Stoakes
Date: Thu Jan 08 2026 - 12:44:38 EST


On Tue, Jan 06, 2026 at 01:20:29PM -0800, Suren Baghdasaryan wrote:
> > > > /**
> > > > @@ -210,7 +209,8 @@ int __anon_vma_prepare(struct vm_area_struct *vma)
> > > > spin_lock(&mm->page_table_lock);
> > > > if (likely(!vma->anon_vma)) {
> > > > vma->anon_vma = anon_vma;
> > > > - anon_vma_chain_link(vma, avc, anon_vma);
> > > > + anon_vma_chain_assign(vma, avc, anon_vma);
> > > > + anon_vma_interval_tree_insert(avc, &anon_vma->rb_root);
> > > > anon_vma->num_active_vmas++;
> > > > allocated = NULL;
> > > > avc = NULL;
> > > > @@ -287,20 +287,28 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> > > >
> > > > check_anon_vma_clone(dst, src);
> > > >
> > > > + /*
> > > > + * Allocate AVCs. We don't need an anon_vma lock for this as we
> > > > + * are not updating the anon_vma rbtree nor are we changing
> > > > + * anon_vma statistics.
> > > > + *
> > > > + * We hold the mmap write lock so there's no possibliity of
> > >
> > > To be more specific, we are holding src's mmap write lock. I think
> > > clarifying that will avoid any confusion.
> >
> > Well, it's the same mm for both right? :)
>
> Hmm. I think in dup_mmap()->anon_vma_fork()->anon_vma_clone() call
> chain the dst->vm_mm and src->vm_mm are different, no? After
> assignment at https://elixir.bootlin.com/linux/v6.19-rc4/source/mm/mmap.c#L1779
> src->vm_mm is pointing to oldmm while dst->vm_mm is pointing to mm. Am
> I reading this wrong?

Yup that's right sorry, and I even make that clear elsewhere, I'll send a
fix-patch or something on the v2.

Cheers, Lorenzo