RBtree: move wmb after node write
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 May 2011 20:23:56 +0000 (16:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 30 May 2011 20:23:56 +0000 (16:23 -0400)
We need to write all the new info into the node before we publish it
(make it visible to readers).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu-rbtree.c

index cb823b27e6b118f262b3124de9bbf34d6766fdb3..c0550d190b0b8708c74c3bc4971d00a6d16f4f0c 100644 (file)
@@ -915,17 +915,21 @@ int rcu_rbtree_insert(struct rcu_rbtree *rbtree,
        else
                set_parent(z, y, IS_RIGHT);
 
-       /*
-        * Order stores to z (children/parents) before stores that will make it
-        * visible to the rest of the tree.
-        */
-       cmm_smp_wmb();
-
        if (rcu_rbtree_is_nil(rbtree, y)) {
+               /*
+                * Order stores to z (children/parents) before stores
+                * that will make it visible to the rest of the tree.
+                */
+               cmm_smp_wmb();
                _CMM_STORE_SHARED(rbtree->root, z);
        } else if (rbtree->comp(z->key, y->key) < 0) {
                set_left_dup_decay(rbtree, y, z, &top, &top_child,
                                &top_child_pos);
+               /*
+                * Order stores to z (children/parents) before stores
+                * that will make it visible to the rest of the tree.
+                */
+               cmm_smp_wmb();
                if (rcu_rbtree_is_nil(rbtree, top))
                        _CMM_STORE_SHARED(rbtree->root, top_child);
                else if (top_child_pos == IS_LEFT)
@@ -936,6 +940,11 @@ int rcu_rbtree_insert(struct rcu_rbtree *rbtree,
        } else {
                set_right_dup_decay(rbtree, y, z, &top, &top_child,
                                &top_child_pos);
+               /*
+                * Order stores to z (children/parents) before stores
+                * that will make it visible to the rest of the tree.
+                */
+               cmm_smp_wmb();
                if (rcu_rbtree_is_nil(rbtree, top))
                        _CMM_STORE_SHARED(rbtree->root, top_child);
                else if (top_child_pos == IS_LEFT)
@@ -981,7 +990,6 @@ void rcu_rbtree_transplant(struct rcu_rbtree *rbtree,
                _CMM_STORE_SHARED(rbtree->root, v);
        } else {
                set_parent(v, get_parent(u), get_pos(u));
-               cmm_smp_wmb();  /* write into node before publish */
 
                if (get_pos(u) == IS_LEFT) {
                        _set_left_dup_decay(rbtree, get_parent(u), v,
@@ -993,6 +1001,8 @@ void rcu_rbtree_transplant(struct rcu_rbtree *rbtree,
                                        &top, &top_child, &top_child_pos);
                }
 
+               cmm_smp_wmb();  /* write into node before publish */
+
                if (rcu_rbtree_is_nil(rbtree, top))
                        _CMM_STORE_SHARED(rbtree->root, top_child);
                else if (top_child_pos == IS_LEFT)
This page took 0.027732 seconds and 4 git commands to generate.