[PATCH 1/2] maple_tree: Use kfree_rcu in ma_free_rcu

Pedro Falcato pfalcato at suse.de
Wed Aug 6 03:20:19 PDT 2025


On Tue, Aug 05, 2025 at 09:25:13PM -0400, Liam R. Howlett wrote:
> * Pedro Falcato <pfalcato at suse.de> [250718 13:21]:
> > kfree_rcu is an optimized version of call_rcu + kfree. It used to not be
> > possible to call it on non-kmalloc objects, but this restriction was
> > lifted ever since SLOB was dropped from the kernel, and since commit
> > 6c6c47b063b5 ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()").
> > 
> > Thus, replace call_rcu + mt_free_rcu with kfree_rcu.
> [snip]
> >  static void mt_set_height(struct maple_tree *mt, unsigned char height)
> > @@ -5281,7 +5274,7 @@ static void mt_free_walk(struct rcu_head *head)
> >  	mt_free_bulk(node->slot_len, slots);
> >  
> >  free_leaf:
> > -	mt_free_rcu(&node->rcu);
> > +	mt_free_one(node);
> 
> Why are we still using mt_free_one()?  Couldn't this also be dropped in
> favour of kfree() or does kfree() not work for kmem_cache?

kfree() also works (since SLOB was dropped). I thought you wanted mt_free_one
for style points, but I can replace all calls with a direct kfree() if you prefer.

-- 
Pedro



More information about the maple-tree mailing list