[PATCH RFC 00/12] mm/vmalloc: migrate vmap_area indexing from rb-tree to maple-tree

Matthew Wilcox willy at infradead.org
Tue Jun 16 11:07:57 PDT 2026


On Mon, Jun 15, 2026 at 11:52:22AM +0200, Uladzislau Rezki wrote:
> On Sun, Jun 14, 2026 at 12:15:28AM +0100, Matthew Wilcox wrote:
> > What I don't understand is why you maintain a separate "free" tree.
> > It should not be necessary any more, but maybe you tried removing it
> > already and found a performance problem?
>
> We maintain it in order to split several entities. That prevents
> interfering between allocated data and vmap-free-space manager.
> So in that case one context can easily access allocated data, for
> example vread iterator, etc., whereas another can do an allocation.
> 
> So by splitting parts i minimize lock-contention.

Sure, but there are many ways to reduce lock contention.  One is to not
take locks at all; the maple tree is RCU-safe, so you can read the tree
holding only the RCU read lock, as long as you obey the RCU rules.

Specifically:
 - Write side has to RCU-free the objects that are stored in the tree
 - Read side has to trylock the objects it finds (and retry the walk
   if the trylock fails)
 - Read side can see a mixture of objects if the tree is changed while
   it is reading, but for any given index in the tree it is guaranteed
   to see one of the objects which has been referred to by that index.
   That is, if the write side overwrites an index that referred to
   object A with object B, the reader will see either object A or B.
   It will not see NULL and it will not see any other object.
 - If the write side stores both object C and object D in the tree,
   the read side may see neither, both, only C or only D.



More information about the maple-tree mailing list