Re: [PATCH RESEND v3 01/10] mm/vma: rename VMA_LOCK_OFFSET to VM_REFCNT_EXCLUDE_READERS_FLAG

Lorenzo Stoakes
2026-01-23T13:28:30Z

On Thu, Jan 22, 2026 at 08:37:51AM -0800, Suren Baghdasaryan wrote:
> On Thu, Jan 22, 2026 at 5:02 AM Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com> wrote:
> >
> > The VMA_LOCK_OFFSET value encodes a flag which vma->vm_refcnt is set to in
> > order to indicate that a VMA is in the process of having VMA read-locks
> > excluded in __vma_enter_locked() (that is, first checking if there are any
> > VMA read locks held, and if there are, waiting on them to be released).
> >
> > This happens when a VMA write lock is being established, or a VMA is being
> > marked detached and discovers that the VMA reference count is elevated due
> > to read-locks temporarily elevating the reference count only to discover a
> > VMA write lock is in place.
> >
> > The naming does not convey any of this, so rename VMA_LOCK_OFFSET to
> > VM_REFCNT_EXCLUDE_READERS_FLAG (with a sensible new prefix to differentiate
> > from the newly introduced VMA_*_BIT flags).
> >
> > Also rename VMA_REF_LIMIT to VM_REFCNT_LIMIT to make this consistent also.
> >
> > Update comments to reflect this.
> >
> > No functional change intended.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> Thanks for the cleanup Lorenzo, and sorry for the delay in reviewing
> your patches. I finally have some time and will try to finish my
> review today.
>
> Reviewed-by: Suren Baghdasaryan <surenb@google.com>

Thanks.

>
> > ---
> > include/linux/mm_types.h | 17 +++++++++++++----
> > include/linux/mmap_lock.h | 14 ++++++++------
> > mm/mmap_lock.c | 17 ++++++++++-------
> > 3 files changed, 31 insertions(+), 17 deletions(-)
> >
> > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> > index 78950eb8926d..94de392ed3c5 100644
> > --- a/include/linux/mm_types.h
> > +++ b/include/linux/mm_types.h
> > @@ -752,8 +752,17 @@ static inline struct anon_vma_name *anon_vma_name_alloc(const char *name)
> > }
> > #endif
> >
> > -#define VMA_LOCK_OFFSET 0x40000000
> > -#define VMA_REF_LIMIT (VMA_LOCK_OFFSET - 1)
> > +/*
> > + * WHile __vma_enter_locked() is working to ensure are no read-locks held on a
>
> s/WHile/While

Oops thanks. Will fix on respin.