aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-08-22 17:46:01 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-22 14:37:02 -0500
commit200668ba0839e664f0e4d0bcdc55ab5a163a418a (patch)
treeefbfbd177a8fd190bd292d6967b1661511269c0b /vl.c
parent6e23063c469c0d90d14b376a696d87149e2a1aa4 (diff)
Do not drop global mutex for polled main loop runs
If we call select without a timeout, it's more efficient to keep the global mutex locked as we may otherwise just play ping pong with a vcpu thread contending for it. This is particularly important for TCG mode where we run in lock-step with the vcpu thread. 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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/vl.c b/vl.c
index 5f1a17704b..c52937a151 100644
--- a/vl.c
+++ b/vl.c
@@ -1349,9 +1349,15 @@ void main_loop_wait(int nonblocking)
qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds);
slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
- qemu_mutex_unlock_iothread();
+ if (timeout > 0) {
+ qemu_mutex_unlock_iothread();
+ }
+
ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
- qemu_mutex_lock_iothread();
+
+ if (timeout > 0) {
+ qemu_mutex_lock_iothread();
+ }
qemu_iohandler_poll(&rfds, &wfds, &xfds, ret);
slirp_select_poll(&rfds, &wfds, &xfds, (ret < 0));