Re: [RFC PATCH 1/5] mm/mmap_lock: add vma_start_read_rcu() helper
From: Lorenzo Stoakes (ARM)
Date: Tue Dec 01 2026 - 08:24:54 EST
NAK. You're not doing this. Any of it, sorry.
On Tue, Dec 01, 2026 at 09:11:31PM +0800, Chuanhua Han wrote:
> A later patch makes the MGLRU aging walk lock VMAs one at a time instead
> of holding mmap_lock for the whole mm. The walk only tries to read-lock
> each VMA it finds under RCU, and skips the VMA if its lock is held for
> write, rather than waiting for the writer. It does so in two places:
No.
>
> - While iterating the VMA tree under RCU.
>
> - While holding a PTE lock, inside the RCU read side critical section
> of pte_offset_map(), to hand the VMA lock off to the next VMA in
> the same PTE table without dropping the PTE lock. Waiting there
> could deadlock: a writer such as mprotect() takes the PTE lock
> after the VMA write lock.
>
No.
> vma_start_read() does not fit the second place, and is awkward in the
> first. When it fails, it leaves the RCU read side critical section,
> which the PTE table mapped by pte_offset_map() depends on, and the
> iteration has to look the next VMA up again. If the VMA has been
> recycled for another mm, it also mmdrop()s that mm, and __mmdrop() is
> heavy enough that vma_start_read() already defers it until after RCU;
> it should not run under a PTE lock either. lock_vma_under_rcu() and
> lock_next_vma() build on vma_start_read() and, on failure, retry or
> fall back to mmap_lock. The walk cannot open code the locking, which
> relies on helpers private to mm/mmap_lock.c.
NO.
>
> Move the body of vma_start_read() into __vma_start_read(), which stays
> in the RCU read side critical section and returns the other mm through
> @drop_mm instead of dropping it, and rebuild vma_start_read() on top
> of it with the same behavior.
No.
>
> Add vma_start_read_rcu() on top of __vma_start_read(). It returns NULL
> both when the VMA cannot be locked and when it is detached, since the
> walk skips it either way. The caller mmdrop()s the mm returned in
> @drop_mm after dropping its spinlocks and leaving RCU, and, as with
> any VMA found under RCU, checks that the locked VMA still covers the
> range it expects.
No.
>
> No functional change.
Not true, you're creating a brand new API and expecting VMA maintainers to
maintain it indefinitely.
Also to give you free review time.
>
> Signed-off-by: Chuanhua Han <hanchuanhua@xxxxxxxxxx>
No thanks.
As VMA co-maintainer let me just make this simple - I am not interested in
changes like this from unknown people, at all. Sorry.
LLMs have changed the landscape. Do smaller changes first. I have no
confidence you understand any of it.
--
Cheers, Lorenzo