|
|
ed5979 |
From 3d823dda6832b76fd3d776131008107b0b0f7166 Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
ed5979 |
Date: Thu, 9 Mar 2023 08:24:36 -0500
|
|
|
ed5979 |
Subject: [PATCH 12/12] async: clarify usage of barriers in the polling case
|
|
|
ed5979 |
|
|
|
ed5979 |
RH-Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
ed5979 |
RH-MergeRequest: 158: qatomic: add smp_mb__before/after_rmw()
|
|
|
ed5979 |
RH-Bugzilla: 2175660
|
|
|
ed5979 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
|
|
|
ed5979 |
RH-Commit: [9/9] b4ea298d75a75bb61e07a27d1296e0095fbc2bbf (eesposit/qemu-kvm)
|
|
|
ed5979 |
|
|
|
ed5979 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175660
|
|
|
ed5979 |
|
|
|
ed5979 |
commit 6229438cca037d42f44a96d38feb15cb102a444f
|
|
|
ed5979 |
Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ed5979 |
Date: Mon Mar 6 10:43:52 2023 +0100
|
|
|
ed5979 |
|
|
|
ed5979 |
async: clarify usage of barriers in the polling case
|
|
|
ed5979 |
|
|
|
ed5979 |
Explain that aio_context_notifier_poll() relies on
|
|
|
ed5979 |
aio_notify_accept() to catch all the memory writes that were
|
|
|
ed5979 |
done before ctx->notified was set to true.
|
|
|
ed5979 |
|
|
|
ed5979 |
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
|
|
|
ed5979 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ed5979 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
util/async.c | 10 ++++++++--
|
|
|
ed5979 |
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/util/async.c b/util/async.c
|
|
|
ed5979 |
index 37d3e6036d..e0846baf93 100644
|
|
|
ed5979 |
--- a/util/async.c
|
|
|
ed5979 |
+++ b/util/async.c
|
|
|
ed5979 |
@@ -472,8 +472,9 @@ void aio_notify_accept(AioContext *ctx)
|
|
|
ed5979 |
qatomic_set(&ctx->notified, false);
|
|
|
ed5979 |
|
|
|
ed5979 |
/*
|
|
|
ed5979 |
- * Write ctx->notified before reading e.g. bh->flags. Pairs with smp_wmb
|
|
|
ed5979 |
- * in aio_notify.
|
|
|
ed5979 |
+ * Order reads of ctx->notified (in aio_context_notifier_poll()) and the
|
|
|
ed5979 |
+ * above clearing of ctx->notified before reads of e.g. bh->flags. Pairs
|
|
|
ed5979 |
+ * with smp_wmb() in aio_notify.
|
|
|
ed5979 |
*/
|
|
|
ed5979 |
smp_mb();
|
|
|
ed5979 |
}
|
|
|
ed5979 |
@@ -496,6 +497,11 @@ static bool aio_context_notifier_poll(void *opaque)
|
|
|
ed5979 |
EventNotifier *e = opaque;
|
|
|
ed5979 |
AioContext *ctx = container_of(e, AioContext, notifier);
|
|
|
ed5979 |
|
|
|
ed5979 |
+ /*
|
|
|
ed5979 |
+ * No need for load-acquire because we just want to kick the
|
|
|
ed5979 |
+ * event loop. aio_notify_accept() takes care of synchronizing
|
|
|
ed5979 |
+ * the event loop with the producers.
|
|
|
ed5979 |
+ */
|
|
|
ed5979 |
return qatomic_read(&ctx->notified);
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.39.1
|
|
|
ed5979 |
|