Re: [PATCH v4 03/10] mm/vma: rename is_vma_write_only(), separate out shared refcount put

From: Lorenzo Stoakes

Date: Mon Jan 26 2026 - 04:47:54 EST


On Sun, Jan 25, 2026 at 09:36:19PM -0800, Suren Baghdasaryan wrote:
> On Fri, Jan 23, 2026 at 12:12 PM Lorenzo Stoakes
> <lorenzo.stoakes@xxxxxxxxxx> wrote:
> >
> > The is_vma_writer_only() function is misnamed - this isn't determining if
> > there is only a write lock, as it checks for the presence of the
> > VM_REFCNT_EXCLUDE_READERS_FLAG.
> >
> > Really, it is checking to see whether readers are excluded, with a
> > possibility of a false positive in the case of a detachment (there we
> > expect the vma->vm_refcnt to eventually be set to
> > VM_REFCNT_EXCLUDE_READERS_FLAG, whereas for an attached VMA we expect it to
> > eventually be set to VM_REFCNT_EXCLUDE_READERS_FLAG + 1).
> >
> > Rename the function accordingly.
> >
> > Relatedly, we use a __refcount_dec_and_test() primitive directly in
> > vma_refcount_put(), using the old value to determine what the reference
> > count ought to be after the operation is complete (ignoring racing
> > reference count adjustments).
> >
> > Wrap this into a __vma_refcount_put_return() function, which we can then
> > utilise in vma_mark_detached() and thus keep the refcount primitive usage
> > abstracted.
> >
> > This function, as the name implies, returns the value after the reference
> > count has been updated.
> >
> > This reduces duplication in the two invocations of this function.
> >
> > Also adjust comments, removing duplicative comments covered elsewhere and
> > adding more to aid understanding.
> >
> > No functional change intended.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
>
> Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>

Thanks!