Re: [RFC PATCH 1/5] mm/mmap_lock: add vma_start_read_rcu() helper
From: Lorenzo Stoakes (ARM)
Date: Wed Dec 02 2026 - 04:10:38 EST
On Tue, Dec 01, 2026 at 06:49:55PM -0800, Suren Baghdasaryan wrote:
> On Tue, Dec 1, 2026 at 5:24 PM chuanhua han <hanchuanhua802@xxxxxxxxx> wrote:
> > I did use an AI assistant for this series and should have said so, sorry. I'll start with smaller MGLRU patches.
Thank you, I appreciate your candour!
> >
> > The mmap_lock waits behind the MGLRU walk do cause frame drops on our
> > phones, so I'd still like to fix that at some point. If the MGLRU
> > maintainers have a preferred direction, I'm happy to hear it.
>
> I looked ahead at what you are doing later in the patchset and yeah,
> that's definitely not something I'm comfortable with. Lockless VMA
> walks are quite complex, just look at the lock_next_vma()
> implementation. Speaking of which, from a quick look at your
> walk_trylock_next_vma(), I think it might have been much easier to add
> an option for lock_next_vma() to not fall back to mmap_lock, which I
> think would have been enough to fit your usecase. I didn't spend much
> time exploring that direction but it might be a much simpler change.
Yeah I agree making a version of lock_next_vma() that doesn't fallback makes
sense, but I think best way is to model it on the BPF user, i.e. replace the
open-coded work there with a variant that permits it.
Then obviously others who have a use for it can do so.
Maybe try_lock_next_vma(), since lock_next_vma() is trying to guarantee a lock
either way?
>
> Also a side-note about drop_mm part in this patch. In [1] Lorenzo
> recently changed vma_start_read() to use mmdrop_async(), so that
> "mmdrop() is a heavy operation" thing does not apply anymore.
Yup :)
>
> [1] https://lore.kernel.org/all/20261124-vma-read-lock-mmdrop-async-v1-1-257f99f551de@xxxxxxxxxx/
--
Cheers, Lorenzo