glib: fix g_poll early timeout on windows
PATCH v5 1/1 glib: fix g_poll early timeout on windows
From: Sangho Park <[email protected]>
g_poll has a problem on Windows when using
timeouts < 10ms, in glib/gpoll.c:
/* If not, and we have a significant timeout, poll again with
* timeout then. Note that this will return indication for only
* one event, or only for messages. We ignore timeouts less than
* ten milliseconds as they are mostly pointless on Windows, the
* MsgWaitForMultipleObjectsEx() call will timeout right away
* anyway.
*/
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);
so whenever g_poll is called with timeout < 10ms it does a quick poll instead of wait, this causes significant performance degradation of QEMU, thus we should use WaitForMultipleObjectsEx directly
--- include/glib-compat.h | 9 +++- util/oslib-win32.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-)
include/glib-compat.h +8 -1
@@ -24,7 +24,14 @@ static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function, }#endif -#if !GLIB_CHECK_VERSION (2 ,20 ,0 ) +#ifdef _WIN32 +/* +* g_poll has a problem on Windows when using +* timeouts < 10ms, so use wrapper. +*/ +#define g_poll (fds, nfds, timeout) g_poll_fixed(fds, nfds, timeout) +gint g_poll_fixed (GPollFD *fds,guint nfds,gint timeout); +#elif !GLIB_CHECK_VERSION (2 ,20 ,0 )/* * Glib before 2.20.0 doesn't implement g_poll, so wrap it to compile properly * on older systems.
util/oslib-win32.c +112 -0
115 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Stefan Hajnoczi
AppliedQuoted 20 lines · Stanislav Vorobiov
From: Sangho Park <[email protected]>
g_pollhas a problem on Windows when using
timeouts < 10ms, inglib/gpoll.c:/* If not, and we have a significant timeout, poll again with
* timeout then. Note that this will return indication for only
* one event, or only for messages. We ignore timeouts less than
* ten milliseconds as they are mostly pointless on Windows, the
*MsgWaitForMultipleObjectsEx()call will timeout right away
* anyway.
*/
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
retval =poll_rest(poll_msgs, handles, nhandles, fds, nfds, timeout);so whenever
g_pollis called with timeout < 10ms it does a quick poll instead of wait, this causes significant performance degradation of QEMU, thus we should use WaitForMultipleObjectsEx directly
Quoted 5 lines
Signed-off-by Stanislav Vorobiov <[email protected]>--- include/glib-compat.h | 9 +++- util/oslib-win32.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
Am 09.05.2014 20:57, schrieb Stefan Hajnoczi:
Quoted 27 lines · Stanislav Vorobiov
Quoted 20 lines
From: Sangho Park <[email protected]>
g_pollhas a problem on Windows when using
timeouts < 10ms, inglib/gpoll.c:/* If not, and we have a significant timeout, poll again with
* timeout then. Note that this will return indication for only
* one event, or only for messages. We ignore timeouts less than
* ten milliseconds as they are mostly pointless on Windows, the
*MsgWaitForMultipleObjectsEx()call will timeout right away
* anyway.
*/
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
retval =poll_rest(poll_msgs, handles, nhandles, fds, nfds, timeout);so whenever
g_pollis called with timeout < 10ms it does a quick poll instead of wait, this causes significant performance degradation of QEMU, thus we should use WaitForMultipleObjectsEx directlyQuoted 5 lines
Signed-off-by Stanislav Vorobiov <[email protected]>--- include/glib-compat.h | 9 +++- util/oslib-win32.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-)
Quoted 5 lines
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/blockStefan
Hi,
the patch breaks hard disk i/o: a 64 bit executable built with MinGW-w64 will no longer boot a ReactOS image (BIOS fails to detect a bootable disk). Booting a Linux CDROM seems to work and is indeed much faster.
Regards
Stefan
Hi,
Could you please provide URL to download that image so that I could reproduce this problem ? Also, qemu command line would be nice.
btw, I won't be able to look into this during next week, so some help from someone else would be nice. I'll try to take a look later today however...
Quoted 46 lines · Stefan Weil
Am 09.05.2014 20:57, schrieb Stefan Hajnoczi:
Quoted 27 lines · Stanislav Vorobiov
Quoted 20 lines
From: Sangho Park <[email protected]>
g_pollhas a problem on Windows when using
timeouts < 10ms, inglib/gpoll.c:/* If not, and we have a significant timeout, poll again with
* timeout then. Note that this will return indication for only
* one event, or only for messages. We ignore timeouts less than
* ten milliseconds as they are mostly pointless on Windows, the
*MsgWaitForMultipleObjectsEx()call will timeout right away
* anyway.
*/
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
retval =poll_rest(poll_msgs, handles, nhandles, fds, nfds, timeout);so whenever
g_pollis called with timeout < 10ms it does a quick poll instead of wait, this causes significant performance degradation of QEMU, thus we should use WaitForMultipleObjectsEx directlyQuoted 5 lines
Signed-off-by Stanislav Vorobiov <[email protected]>--- include/glib-compat.h | 9 +++- util/oslib-win32.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-)Quoted 5 lines
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/blockStefan
Hi,
the patch breaks hard disk i/o: a 64 bit executable built with MinGW-w64 will no longer boot a ReactOS image (BIOS fails to detect a bootable disk). Booting a Linux CDROM seems to work and is indeed much faster.
Regards
Stefan
Am 16.05.2014 08:44, schrieb Stanislav Vorobiov:
Quoted 9 lines
Hi,
Could you please provide URL to download that image so that I could reproduce this problem ? Also, qemu command line would be nice.
btw, I won't be able to look into this during next week, so some help from someone else would be nice. I'll try to take a look later today however...
There is no need to download an image. Any image will do for this test. The command line also does not matter. I just tried this:
i386-softmmu/qemu-system-i386 -L pc-bios vl.c
With the current qemu trunk and a 64 bit default build (MinGW-w64 native or cross), the BIOS cannot read the harddisk. When I undefine g_poll in qemu-timer.c, QEMU can read it and the BIOS will report that vl.c is not a bootable disk (which is quite obvious).
Stefan
Il 16/05/2014 07:00, Stefan Weil ha scritto:
Quoted 5 lines
Hi,
the patch breaks hard disk i/o: a 64 bit executable built with MinGW-w64 will no longer boot a ReactOS image (BIOS fails to detect a bootable disk). Booting a Linux CDROM seems to work and is indeed much faster.
What about a 32-bit executable?
Paolo
Am 16.05.2014 13:32, schrieb Paolo Bonzini:
Quoted 10 lines
Il 16/05/2014 07:00, Stefan Weil ha scritto:
Quoted 5 lines
Hi,
the patch breaks hard disk i/o: a 64 bit executable built with MinGW-w64 will no longer boot a ReactOS image (BIOS fails to detect a bootable disk). Booting a Linux CDROM seems to work and is indeed much faster.
What about a 32-bit executable?
Paolo
They show the same effect. When I reported the problem, I had no test result for 32 bit, now I have one. Native builds on Windows are terribly slow and take a lot of time...
Summary: Neither 32 nor 64 bit qemu system emulation on Windows hosts can read hard disk images with this patch applied. It's sufficient to test any image and see whether the BIOS detects the hard disk.
Stefan