]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Rework internal walk.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 12 Mar 2019 18:52:18 +0000 (14:52 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 31 Jul 2019 14:52:41 +0000 (10:52 -0400)
Reduce possible calls to get an rcu entry.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index cd3b099b5058d46d4003caba66576e72efbad90a..8a53c362b56176e9342da4067846e952e6472472 100644 (file)
@@ -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;
        }