Re: [PATCH v2 3/8] mm/rmap: remove unnecessary root lock dance in anon_vma clone, unmap

From: Andrew Morton

Date: Wed Jan 14 2026 - 17:12:06 EST


On Wed, 14 Jan 2026 17:54:07 +0000 Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> wrote:

> > > {
> > > @@ -310,26 +284,28 @@ static void cleanup_partial_anon_vmas(struct vm_area_struct *vma);
> > > int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
> > > {
> > > struct anon_vma_chain *avc, *pavc;
> > > - struct anon_vma *root = NULL;
> > >
> > > check_anon_vma_clone(dst, src);
> > >
> > > if (!src->anon_vma)
> > > return 0;
> > >
> > > + check_anon_vma_clone(dst, src);
> >
> > check_anon_vma_clone() was already called 4 lines above. I'm guessing
> > this was accidentally carried over from the previous version?
> >
>
> Yeah I don't know why this is here, in the tree it isn't, maybe Andrew noticed
> and elided? :)

Thanks, but I wouldn't have done that silently.

The later "mm/rmap: separate out fork-only logic on anon_vma_clone()" removed it:

: @@ -281,17 +317,17 @@ static void cleanup_partial_anon_vmas(st
: *
: * Returns: 0 on success, -ENOMEM on failure.
: */
: -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
: +int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src,
: + enum vma_operation operation)
: {
: struct anon_vma_chain *avc, *pavc;
: + struct anon_vma *active_anon_vma = src->anon_vma;
:
: - check_anon_vma_clone(dst, src);
: + check_anon_vma_clone(dst, src, operation);
:
: - if (!src->anon_vma)
: + if (!active_anon_vma)
: return 0;
:
: - 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