On 4/30/23 12:25, Paolo Bonzini wrote:
Use a store-release when enqueuing a new call_rcu, and a load-acquire
when dequeuing; and read the tail after checking that node->next is
consistent, which is the standard message passing pattern and it is
clearer than mb_read/mb_set.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
util/rcu.c | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/util/rcu.c b/util/rcu.c
index e5b6e52be6f8..867607cd5a1e 100644
--- a/util/rcu.c
+++ b/util/rcu.c
@@ -189,8 +189,22 @@ static void enqueue(struct rcu_head *node)
struct rcu_head **old_tail;
node->next = NULL;
+
+ /*
+ * Make this node the tail of the list. The node will be
+ * used by further enqueue operations, but it will not
+ * be dequeued yet...
+ */
old_tail = qatomic_xchg(&tail, &node->next);
- qatomic_mb_set(old_tail, node);
+
+ /*
+ * ... until it is pointed to from another item in the list.
+ * In the meanwhile, try_dequeue() will find a NULL next pointer
Either "In the meantime" or "Meanwhile" (noun vs adverb).
E.g. "Meanwhile, at Try Dequeue's volcano lair..." :-)
+ /* If the head node has NULL in its next pointer, the value is
+ * wrong and we need to wait until its enqueuer finishes the update.
+ */
/*
*
*/
I know surrounding code is different, but slowly it will all be edited.
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
r~