aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-08-22 17:46:02 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-22 14:37:02 -0500
commitc9f711a5d31e22dac932c1c01e9c0f97caff0988 (patch)
tree1d7b980c02326f221d70778ca1e7798e66439d24 /vl.c
parent200668ba0839e664f0e4d0bcdc55ab5a163a418a (diff)
downloadqemu-c9f711a5d31e22dac932c1c01e9c0f97caff0988.zip
qemu-c9f711a5d31e22dac932c1c01e9c0f97caff0988.tar.gz
qemu-c9f711a5d31e22dac932c1c01e9c0f97caff0988.tar.bz2
Poll main loop after I/O events were received
Polling until select returns empty fdsets helps to reduce the switches between iothread and vcpus. The benefit of this patch is best visible when running an SMP guest on an SMP host in emulation mode. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/vl.c b/vl.c
index c52937a..9cd67a3 100644
--- a/vl.c
+++ b/vl.c
@@ -1321,7 +1321,7 @@ void qemu_system_vmstop_request(int reason)
qemu_notify_event();
}
-void main_loop_wait(int nonblocking)
+int main_loop_wait(int nonblocking)
{
fd_set rfds, wfds, xfds;
int ret, nfds;
@@ -1368,6 +1368,7 @@ void main_loop_wait(int nonblocking)
them. */
qemu_bh_poll();
+ return ret;
}
#ifndef CONFIG_IOTHREAD
@@ -1385,7 +1386,8 @@ qemu_irq qemu_system_powerdown;
static void main_loop(void)
{
- bool nonblocking = false;
+ bool nonblocking;
+ int last_io __attribute__ ((unused)) = 0;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
@@ -1394,7 +1396,9 @@ static void main_loop(void)
qemu_main_loop_start();
for (;;) {
-#ifndef CONFIG_IOTHREAD
+#ifdef CONFIG_IOTHREAD
+ nonblocking = !kvm_enabled() && last_io > 0;
+#else
nonblocking = cpu_exec_all();
if (vm_request_pending()) {
nonblocking = true;
@@ -1403,7 +1407,7 @@ static void main_loop(void)
#ifdef CONFIG_PROFILER
ti = profile_getclock();
#endif
- main_loop_wait(nonblocking);
+ last_io = main_loop_wait(nonblocking);
#ifdef CONFIG_PROFILER
dev_time += profile_getclock() - ti;
#endif