Re: [PATCH v2] docs/mm: add VMA locks documentation

From: Lorenzo Stoakes
Date: Thu Nov 14 2024 - 15:46:32 EST


On Tue, Nov 12, 2024 at 10:15:44AM -0500, Liam R. Howlett wrote:
> * Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> [241108 08:57]:
> > +VMA locks are special in that you must obtain an mmap **write** lock **first**
> > +in order to obtain a VMA **write** lock. A VMA **read** lock however can be
> > +obtained without any other lock (:c:func:`!lock_vma_under_rcu` will acquire then
> > +release an RCU lock to lookup the VMA for you).
>
> This reduces the impact of a writer on readers by only impacting
> conflicting areas of the vma tree.

Sorry I totally missed this last time round, will add a note.


> > + ================================= ===================== ======================================== ===============
> > + Field Configuration option Description Write lock
> > + ================================= ===================== ======================================== ===============
> > + :c:member:`!anon_name` CONFIG_ANON_VMA_NAME A field for storing a mmap write,
> > + :c:struct:`!struct anon_vma_name` VMA write.
> > + object providing a name for anonymous
> > + mappings, or :c:macro:`!NULL` if none
> > + is set or the VMA is file-backed.
>
> These are ref counted and can be shared by more than one vma for
> scalability.
>
> > + :c:member:`!swap_readahead_info` CONFIG_SWAP Metadata used by the swap mechanism mmap read,
> > + to perform readahead. This field is swap-specific
> > + accessed atomically. lock.
> > + :c:member:`!vm_policy` CONFIG_NUMA :c:type:`!mempolicy` object which mmap write,
> > + describes the NUMA behaviour of the VMA write.
> > + VMA.
>
> These are also ref counted for scalability.

I think actually on second thoughts I will add notes about this in v3, as it at
least gives a bit more context.