All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH] async: Fix aio_notify_accept
@ 2018-08-03 15:49 Fam Zheng
  2018-08-03 16:51 ` Paolo Bonzini
  2018-08-03 17:08 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Fam Zheng @ 2018-08-03 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Fam Zheng, Stefan Hajnoczi, qemu-block

>From main loop, bdrv_set_aio_context() can call IOThread's aio_poll().
That breaks aio_notify() because the ctx->notifier event can get cleared
too early by this which causes IOThread hanging.

See https://bugzilla.redhat.com/show_bug.cgi?id=1562750 for details.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 util/async.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/util/async.c b/util/async.c
index 05979f8014..c6e8aebc3a 100644
--- a/util/async.c
+++ b/util/async.c
@@ -355,7 +355,11 @@ void aio_notify(AioContext *ctx)
 
 void aio_notify_accept(AioContext *ctx)
 {
-    if (atomic_xchg(&ctx->notified, false)) {
+    /* If ctx->notify_me >= 2, another aio_poll() is waiting which may need the
+     * ctx->notifier event to wake up, so don't already clear it just because "we" are
+     * done iterating. */
+    if (atomic_read(&ctx->notify_me) < 2
+        && atomic_xchg(&ctx->notified, false)) {
         event_notifier_test_and_clear(&ctx->notifier);
     }
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-07  1:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 15:49 [Qemu-devel] [RFC PATCH] async: Fix aio_notify_accept Fam Zheng
2018-08-03 16:51 ` Paolo Bonzini
2018-08-03 17:08 ` Paolo Bonzini
2018-08-07  1:01   ` Fam Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.