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

From: Peter Zijlstra
Date: Wed Jan 15 2025 - 10:39:11 EST


On Wed, Jan 15, 2025 at 04:35:07PM +0100, Peter Zijlstra wrote:

> Consider:
>
> CPU0 CPU1
>
> rcu_read_lock();
> vma = vma_lookup(mm, vaddr);
>
> ... cpu goes sleep for a *long time* ...
>
> __vma_exit_locked();
> vma_area_free()
> ..
> vma = vma_area_alloc();
> vma_mark_attached();
>
> ... comes back once vma is re-used ...
>
> vma_start_read()
> vm_refcount_inc(); // success!!
>
> At which point we need to validate vma is for mm and covers vaddr, which
> is what patch 15 does, no?

Also, critically, we want these reads to happen *after* the refcount
increment.