[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/30] win32: work around main-loop busy loop on socket/fd event
From: |
Paolo Bonzini |
Subject: |
[PULL 28/30] win32: work around main-loop busy loop on socket/fd event |
Date: |
Wed, 2 Oct 2019 18:51:51 +0200 |
From: Marc-André Lureau <address@hidden>
Commit 05e514b1d4d5bd4209e2c8bbc76ff05c85a235f3 introduced an AIO
context optimization to avoid calling event_notifier_test_and_clear() on
ctx->notifier. On Windows, the same notifier is being used to wakeup the
wait on socket events (see commit
d3385eb448e38f828c78f8f68ec5d79c66a58b5d).
The ctx->notifier event is added to the gpoll sources in
aio_set_event_notifier(), aio_ctx_check() should clear the event
regardless of ctx->notified, since Windows sets the event by itself,
bypassing the aio->notified. This fixes qemu not clearing the event
resulting in a busy loop.
Paolo suggested to me on irc to call event_notifier_test_and_clear()
after select() >0 from aio-win32.c's aio_prepare. Unfortunately, not all
fds associated with ctx->notifiers are in AIO fd handlers set.
(qemu_set_nonblock() in util/oslib-win32.c calls qemu_fd_register()).
This is essentially a v2 of a patch that was sent earlier:
https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg00420.html
that resurfaced when James investigated Spice performance issues on Windows:
https://gitlab.freedesktop.org/spice/spice/issues/36
In order to test that patch, I simply tried running test-char on
win32, and it hangs. Applying that patch solves it. QIO idle sources
are not dispatched. I haven't investigated much further, I suspect
source priorities and busy looping still come into play.
This version keeps the "notified" field, so event_notifier_poll()
should still work as expected.
Cc: James Le Cuirot <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/async.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/util/async.c b/util/async.c
index 4e4c7af..ca83e32 100644
--- a/util/async.c
+++ b/util/async.c
@@ -354,7 +354,11 @@ void aio_notify(AioContext *ctx)
void aio_notify_accept(AioContext *ctx)
{
- if (atomic_xchg(&ctx->notified, false)) {
+ if (atomic_xchg(&ctx->notified, false)
+#ifdef WIN32
+ || true
+#endif
+ ) {
event_notifier_test_and_clear(&ctx->notifier);
}
}
--
1.8.3.1
- [PULL 18/30] mips: fix memory leaks in board initialization, (continued)
- [PULL 18/30] mips: fix memory leaks in board initialization, Paolo Bonzini, 2019/10/02
- [PULL 20/30] lm32: do not leak memory on object_new/object_unref, Paolo Bonzini, 2019/10/02
- [PULL 21/30] docker: test-debug: disable LeakSanitizer, Paolo Bonzini, 2019/10/02
- [PULL 19/30] cris: do not leak struct cris_disasm_data, Paolo Bonzini, 2019/10/02
- [PULL 22/30] i386: Add CPUID bit for CLZERO and XSAVEERPTR, Paolo Bonzini, 2019/10/02
- [PULL 23/30] vfio: Turn the container error into an Error handle, Paolo Bonzini, 2019/10/02
- [PULL 25/30] Fix wrong behavior of cpu_memory_rw_debug() function in SMM, Paolo Bonzini, 2019/10/02
- [PULL 26/30] util: WSAEWOULDBLOCK on connect should map to EINPROGRESS, Paolo Bonzini, 2019/10/02
- [PULL 24/30] memory: allow memory_region_register_iommu_notifier() to fail, Paolo Bonzini, 2019/10/02
- [PULL 28/30] win32: work around main-loop busy loop on socket/fd event,
Paolo Bonzini <=
- [PULL 29/30] tests/docker: only enable ubsan for test-clang, Paolo Bonzini, 2019/10/02
- [PULL 30/30] accel/kvm: ensure ret always set, Paolo Bonzini, 2019/10/02
- [PULL 27/30] tests: skip serial test on windows, Paolo Bonzini, 2019/10/02
- Re: [PULL 00/30] Misc patches for 2010-10-02, no-reply, 2019/10/02
- [PULL 00/30] Misc patches for 2010-10-02, Paolo Bonzini, 2019/10/03