From 0f67fd5bdfd5d55ed5b09cadd9c4f5bf1812edc6 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 12 Mar 2019 14:52:18 -0400 Subject: [PATCH] maple_tree: Rework internal walk. Reduce possible calls to get an rcu entry. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index cd3b099b5058..8a53c362b561 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1278,6 +1278,9 @@ done: return ret; } +/* + * Private: Returns true if mas->node is a leaf + */ static inline bool _mas_walk(struct ma_state *mas) { enum maple_type type; @@ -1399,13 +1402,14 @@ void *mas_walk(struct ma_state *mas) void *entry = NULL; unsigned char slot = MAPLE_NODE_SLOTS; bool leaf = false; + void *root = rcu_dereference(mas->tree->ma_root); - if (rcu_dereference(mas->tree->ma_root) == NULL) + if (root == NULL) return NULL; - if (!xa_is_node(mas->tree->ma_root)) { + if (!xa_is_node(root)) { if (mas->last == 0) - return rcu_dereference(mas->tree->ma_root); + return root; return NULL; } -- 2.50.1