From: Liam R. Howlett Date: Tue, 12 Mar 2019 18:52:18 +0000 (-0400) Subject: maple_tree: Rework internal walk. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=77ac5a345fd4527877085271bf27ef3baf1bc1ab;p=users%2Fjedix%2Flinux-maple.git maple_tree: Rework internal walk. Reduce possible calls to get an rcu entry. Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index cd3b099b5058d..8a53c362b5617 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; }