Re: [PATCH v8 11/16] mm: replace vm_lock and detached flag with a reference count
From: Suren Baghdasaryan
Date: Thu Jan 09 2025 - 11:01:22 EST
On Thu, Jan 9, 2025 at 2:36 AM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Wed, 8 Jan 2025 18:30:20 -0800 Suren Baghdasaryan <surenb@xxxxxxxxxx>
> > +
> > +static inline void vma_refcount_put(struct vm_area_struct *vma)
> > +{
> > + int oldcnt;
> > +
> > + if (!__refcount_dec_and_test(&vma->vm_refcnt, &oldcnt)) {
> > + rwsem_release(&vma->vmlock_dep_map, _RET_IP_);
>
> In up_read() rwsem is released reguardless wakeup, which is different
> than what is added here. Nit.
Good point. I'll send a fixup since it's a small change. Thanks!
>
> > +
> > + if (is_vma_writer_only(oldcnt - 1))
> > + rcuwait_wake_up(&vma->vm_mm->vma_writer_wait);
> > + }
> > +}
> ...
> > @@ -735,9 +773,10 @@ static inline bool vma_start_read(struct vm_area_struct *vma)
> > * This pairs with RELEASE semantics in vma_end_write_all().
> > */
> > if (unlikely(vma->vm_lock_seq == raw_read_seqcount(&vma->vm_mm->mm_lock_seq))) {
> > - up_read(&vma->vm_lock.lock);
> > + vma_refcount_put(vma);
> > return false;
> > }
>
> void up_read(struct rw_semaphore *sem)
> {
> rwsem_release(&sem->dep_map, _RET_IP_);
> __up_read(sem);
> }
>