97168e
From 953c5c0982b61b0a3f8f03452844b5487eb22fc7 Mon Sep 17 00:00:00 2001
97168e
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
97168e
Date: Thu, 9 Mar 2023 08:13:17 -0500
97168e
Subject: [PATCH 06/13] aio-wait: switch to smp_mb__after_rmw()
97168e
97168e
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
97168e
RH-MergeRequest: 263: qatomic: add smp_mb__before/after_rmw()
97168e
RH-Bugzilla: 2168472
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
97168e
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
97168e
RH-Acked-by: David Hildenbrand <david@redhat.com>
97168e
RH-Commit: [6/10] 9f30f97754139ffd18d36b2350f9ed4e59ac496e
97168e
97168e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168472
97168e
97168e
commit b532526a07ef3b903ead2e055fe6cc87b41057a3
97168e
Author: Paolo Bonzini <pbonzini@redhat.com>
97168e
Date:   Fri Mar 3 11:03:52 2023 +0100
97168e
97168e
    aio-wait: switch to smp_mb__after_rmw()
97168e
97168e
    The barrier comes after an atomic increment, so it is enough to use
97168e
    smp_mb__after_rmw(); this avoids a double barrier on x86 systems.
97168e
97168e
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
97168e
    Reviewed-by: David Hildenbrand <david@redhat.com>
97168e
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
97168e
97168e
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
97168e
---
97168e
 include/block/aio-wait.h | 2 +-
97168e
 1 file changed, 1 insertion(+), 1 deletion(-)
97168e
97168e
diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h
97168e
index 54840f8622..03b6394c78 100644
97168e
--- a/include/block/aio-wait.h
97168e
+++ b/include/block/aio-wait.h
97168e
@@ -82,7 +82,7 @@ extern AioWait global_aio_wait;
97168e
     /* Increment wait_->num_waiters before evaluating cond. */     \
97168e
     qatomic_inc(&wait_->num_waiters);                              \
97168e
     /* Paired with smp_mb in aio_wait_kick(). */                   \
97168e
-    smp_mb();                                                      \
97168e
+    smp_mb__after_rmw();                                           \
97168e
     if (ctx_ && in_aio_context_home_thread(ctx_)) {                \
97168e
         while ((cond)) {                                           \
97168e
             aio_poll(ctx_, true);                                  \
97168e
-- 
97168e
2.37.3
97168e