[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJuCfpELdDi0G5Tdf0GQRNVvLxFW6HzKN-gfTLW4Yiw0jNRHQQ@mail.gmail.com>
Date: Wed, 9 Jul 2025 07:43:40 -0700
From: Suren Baghdasaryan <surenb@...gle.com>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: akpm@...ux-foundation.org, Liam.Howlett@...cle.com,
lorenzo.stoakes@...cle.com, david@...hat.com, peterx@...hat.com,
jannh@...gle.com, hannes@...xchg.org, mhocko@...nel.org, paulmck@...nel.org,
shuah@...nel.org, adobriyan@...il.com, brauner@...nel.org,
josef@...icpanda.com, yebin10@...wei.com, linux@...ssschuh.net,
willy@...radead.org, osalvador@...e.de, andrii@...nel.org,
ryan.roberts@....com, christophe.leroy@...roup.eu, tjmercier@...gle.com,
kaleshsingh@...gle.com, aha310510@...il.com, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v6 7/8] fs/proc/task_mmu: read proc/pid/maps under per-vma lock
On Wed, Jul 9, 2025 at 3:03 AM Vlastimil Babka <vbabka@...e.cz> wrote:
>
> On 7/4/25 08:07, Suren Baghdasaryan wrote:
> > --- a/mm/mmap_lock.c
> > +++ b/mm/mmap_lock.c
> > @@ -178,6 +178,94 @@ struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm,
> > count_vm_vma_lock_event(VMA_LOCK_ABORT);
> > return NULL;
> > }
> > +
> > +static struct vm_area_struct *lock_vma_under_mmap_lock(struct mm_struct *mm,
> > + struct vma_iterator *iter,
> > + unsigned long address)
> > +{
> > + struct vm_area_struct *vma;
> > + int ret;
> > +
> > + ret = mmap_read_lock_killable(mm);
> > + if (ret)
> > + return ERR_PTR(ret);
> > +
> > + /* Lookup the vma at the last position again under mmap_read_lock */
> > + vma_iter_init(iter, mm, address);
> > + vma = vma_next(iter);
> > + if (vma)
> > + vma_start_read_locked(vma);
>
> This can in theory return false (refcount overflow?) so it should be handled?
Yes, I should handle it by falling back to mmap_lock. Thanks!
>
> > +
> > + mmap_read_unlock(mm);
> > +
> > + return vma;
> > +}
> > +
Powered by blists - more mailing lists