thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
97168e
From 187eb7a418af93375e42298d06e231e2bec3cf00 Mon Sep 17 00:00:00 2001
97168e
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
97168e
Date: Thu, 9 Mar 2023 08:15:42 -0500
97168e
Subject: [PATCH 10/13] async: clarify usage of barriers in the polling case
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: [10/10] 3be07ccc6137a0336becfe63a818d9cbadb38e9c
97168e
97168e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168472
97168e
97168e
commit 6229438cca037d42f44a96d38feb15cb102a444f
97168e
Author: Paolo Bonzini <pbonzini@redhat.com>
97168e
Date:   Mon Mar 6 10:43:52 2023 +0100
97168e
97168e
    async: clarify usage of barriers in the polling case
97168e
97168e
    Explain that aio_context_notifier_poll() relies on
97168e
    aio_notify_accept() to catch all the memory writes that were
97168e
    done before ctx->notified was set to true.
97168e
97168e
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
97168e
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
97168e
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
97168e
97168e
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
97168e
---
97168e
 util/async.c | 10 ++++++++--
97168e
 1 file changed, 8 insertions(+), 2 deletions(-)
97168e
97168e
diff --git a/util/async.c b/util/async.c
97168e
index 795fe699b6..2a63bf90f2 100644
97168e
--- a/util/async.c
97168e
+++ b/util/async.c
97168e
@@ -463,8 +463,9 @@ void aio_notify_accept(AioContext *ctx)
97168e
     qatomic_set(&ctx->notified, false);
97168e
 
97168e
     /*
97168e
-     * Write ctx->notified before reading e.g. bh->flags.  Pairs with smp_wmb
97168e
-     * in aio_notify.
97168e
+     * Order reads of ctx->notified (in aio_context_notifier_poll()) and the
97168e
+     * above clearing of ctx->notified before reads of e.g. bh->flags.  Pairs
97168e
+     * with smp_wmb() in aio_notify.
97168e
      */
97168e
     smp_mb();
97168e
 }
97168e
@@ -487,6 +488,11 @@ static bool aio_context_notifier_poll(void *opaque)
97168e
     EventNotifier *e = opaque;
97168e
     AioContext *ctx = container_of(e, AioContext, notifier);
97168e
 
97168e
+    /*
97168e
+     * No need for load-acquire because we just want to kick the
97168e
+     * event loop.  aio_notify_accept() takes care of synchronizing
97168e
+     * the event loop with the producers.
97168e
+     */
97168e
     return qatomic_read(&ctx->notified);
97168e
 }
97168e
 
97168e
-- 
97168e
2.37.3
97168e