]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
async: clarify usage of barriers in the polling case
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 6 Mar 2023 09:43:52 +0000 (10:43 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 7 Mar 2023 11:39:53 +0000 (12:39 +0100)
Explain that aio_context_notifier_poll() relies on
aio_notify_accept() to catch all the memory writes that were
done before ctx->notified was set to true.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
util/async.c

index e4b494150e7ddf81e7912456f75f7d96b75c9889..21016a1ac7c1c2e5fd2e9a865c15bc30dee260d9 100644 (file)
@@ -474,8 +474,9 @@ void aio_notify_accept(AioContext *ctx)
     qatomic_set(&ctx->notified, false);
 
     /*
-     * Write ctx->notified before reading e.g. bh->flags.  Pairs with smp_wmb
-     * in aio_notify.
+     * Order reads of ctx->notified (in aio_context_notifier_poll()) and the
+     * above clearing of ctx->notified before reads of e.g. bh->flags.  Pairs
+     * with smp_wmb() in aio_notify.
      */
     smp_mb();
 }
@@ -498,6 +499,11 @@ static bool aio_context_notifier_poll(void *opaque)
     EventNotifier *e = opaque;
     AioContext *ctx = container_of(e, AioContext, notifier);
 
+    /*
+     * No need for load-acquire because we just want to kick the
+     * event loop.  aio_notify_accept() takes care of synchronizing
+     * the event loop with the producers.
+     */
     return qatomic_read(&ctx->notified);
 }