[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.0.4 42/63] util/interval-tree: Use qatomic_set_mb in rb_link_n
From: |
Michael Tokarev |
Subject: |
[Stable-8.0.4 42/63] util/interval-tree: Use qatomic_set_mb in rb_link_node |
Date: |
Fri, 4 Aug 2023 22:16:25 +0300 |
From: Richard Henderson <richard.henderson@linaro.org>
Ensure that the stores to rb_left and rb_right are complete before
inserting the new node into the tree. Otherwise a concurrent reader
could see garbage in the new leaf.
Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 4c8baa02d36379507afd17bdea87aabe0aa32ed3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: s/qatomic_set_mb/qatomic_mb_set/ for 8.0 - it was renamed later)
diff --git a/util/interval-tree.c b/util/interval-tree.c
index 5a0ad21b2d..2000cd2935 100644
--- a/util/interval-tree.c
+++ b/util/interval-tree.c
@@ -128,7 +128,11 @@ static inline void rb_link_node(RBNode *node, RBNode
*parent, RBNode **rb_link)
node->rb_parent_color = (uintptr_t)parent;
node->rb_left = node->rb_right = NULL;
- qatomic_set(rb_link, node);
+ /*
+ * Ensure that node is initialized before insertion,
+ * as viewed by a concurrent search.
+ */
+ qatomic_mb_set(rb_link, node);
}
static RBNode *rb_next(RBNode *node)
--
2.39.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |