Re: [PATCH v9 11/17] mm: replace vm_lock and detached flag with a reference count

From: Suren Baghdasaryan
Date: Mon Jan 13 2025 - 16:18:33 EST


On Sun, Jan 12, 2025 at 6:38 PM Wei Yang <richard.weiyang@xxxxxxxxx> wrote:
>
> On Fri, Jan 10, 2025 at 08:25:58PM -0800, Suren Baghdasaryan wrote:
> > static inline void vma_end_read(struct vm_area_struct *vma) {}
> >@@ -908,12 +948,8 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
> > vma->vm_mm = mm;
> > vma->vm_ops = &vma_dummy_vm_ops;
> > INIT_LIST_HEAD(&vma->anon_vma_chain);
> >-#ifdef CONFIG_PER_VMA_LOCK
> >- /* vma is not locked, can't use vma_mark_detached() */
> >- vma->detached = true;
> >-#endif
> > vma_numab_state_init(vma);
> >- vma_lock_init(vma);
> >+ vma_lock_init(vma, false);
>
> vma_init(vma, mm)
> memset(vma, 0, sizeof(*vma))
> ...
> vma_lock_init(vma, false);
>
> It looks the vm_refcnt must be reset.
>
> BTW, I don't figure out why we want to skip the reset of vm_refcnt. Is this
> related to SLAB_TYPESAFE_BY_RCU?

Earlier memset(vma, 0, sizeof(*vma)) already zeroes the entire
structure, so vm_refcnt is already 0 and does not need to be reset
again.

>
> > }
> >
>
> --
> Wei Yang
> Help you, Help me