* [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32
@ 2012-11-23 14:59 Paolo Bonzini
2012-11-26 21:49 ` Anthony Liguori
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2012-11-23 14:59 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
The repeated calls to WaitForMultipleObjects may cause a livelock in aio_poll,
where no progress is made on bottom halves. This patch matches the behavior
of the POSIX code.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
Found by the new unit tests.
aio-win32.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/aio-win32.c b/aio-win32.c
index a84eb71..cec4646 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -173,7 +173,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
}
/* wait until next event */
- for (;;) {
+ while (count > 0) {
int timeout = blocking ? INFINITE : 0;
int ret = WaitForMultipleObjects(count, events, FALSE, timeout);
@@ -209,6 +209,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
g_free(tmp);
}
}
+
+ /* Try again, but only call each handler once. */
+ events[ret - WAIT_OBJECT_0] = events[--count];
}
return progress;
--
1.8.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32
2012-11-23 14:59 [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32 Paolo Bonzini
@ 2012-11-26 21:49 ` Anthony Liguori
0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2012-11-26 21:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Paolo Bonzini <pbonzini@redhat.com> writes:
> The repeated calls to WaitForMultipleObjects may cause a livelock in aio_poll,
> where no progress is made on bottom halves. This patch matches the behavior
> of the POSIX code.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> Found by the new unit tests.
Applied. Thanks.
Regards,
Anthony Liguori
>
> aio-win32.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/aio-win32.c b/aio-win32.c
> index a84eb71..cec4646 100644
> --- a/aio-win32.c
> +++ b/aio-win32.c
> @@ -173,7 +173,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
> }
>
> /* wait until next event */
> - for (;;) {
> + while (count > 0) {
> int timeout = blocking ? INFINITE : 0;
> int ret = WaitForMultipleObjects(count, events, FALSE, timeout);
>
> @@ -209,6 +209,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
> g_free(tmp);
> }
> }
> +
> + /* Try again, but only call each handler once. */
> + events[ret - WAIT_OBJECT_0] = events[--count];
> }
>
> return progress;
> --
> 1.8.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-26 21:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-23 14:59 [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32 Paolo Bonzini
2012-11-26 21:49 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).