Skip to content

Commit 9b60811

Browse files
heatdtehcaster
authored andcommitted
maple_tree: Use kfree_rcu in ma_free_rcu
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 6c6c47b ("mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy()"). Thus, replace call_rcu + mt_free_rcu with kfree_rcu. Signed-off-by: Pedro Falcato <[email protected]> Reviewed-by: Harry Yoo <[email protected]> Reviewed-by: Suren Baghdasaryan <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 551a6e7 commit 9b60811

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/maple_tree.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,6 @@ static inline void mt_free_bulk(size_t size, void __rcu **nodes)
187187
kmem_cache_free_bulk(maple_node_cache, size, (void **)nodes);
188188
}
189189

190-
static void mt_free_rcu(struct rcu_head *head)
191-
{
192-
struct maple_node *node = container_of(head, struct maple_node, rcu);
193-
194-
kmem_cache_free(maple_node_cache, node);
195-
}
196-
197190
/*
198191
* ma_free_rcu() - Use rcu callback to free a maple node
199192
* @node: The node to free
@@ -204,7 +197,7 @@ static void mt_free_rcu(struct rcu_head *head)
204197
static void ma_free_rcu(struct maple_node *node)
205198
{
206199
WARN_ON(node->parent != ma_parent_ptr(node));
207-
call_rcu(&node->rcu, mt_free_rcu);
200+
kfree_rcu(node, rcu);
208201
}
209202

210203
static void mt_set_height(struct maple_tree *mt, unsigned char height)
@@ -5099,7 +5092,7 @@ static void mt_free_walk(struct rcu_head *head)
50995092
mt_free_bulk(node->slot_len, slots);
51005093

51015094
free_leaf:
5102-
mt_free_rcu(&node->rcu);
5095+
mt_free_one(node);
51035096
}
51045097

51055098
static inline void __rcu **mte_destroy_descend(struct maple_enode **enode,
@@ -5183,7 +5176,7 @@ static void mt_destroy_walk(struct maple_enode *enode, struct maple_tree *mt,
51835176

51845177
free_leaf:
51855178
if (free)
5186-
mt_free_rcu(&node->rcu);
5179+
mt_free_one(node);
51875180
else
51885181
mt_clear_meta(mt, node, node->type);
51895182
}

0 commit comments

Comments
 (0)