aboutsummaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorClement Deschamps <clement.deschamps@greensocs.com>2018-10-21 16:21:03 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2018-11-06 21:35:04 +0100
commit013aabdc665e4256b38d8875a1a7b5e030ba98f1 (patch)
treead1051fc658edf56c0867cc1a511cc702f50b2fc /cpus.c
parentfc3d1bad1edf08871275cf469a64e12dae4eba96 (diff)
icount: fix deadlock when all cpus are sleeping
When all cpus are sleeping (e.g in WFI), to avoid a deadlock in the main_loop, wake it up in order to start the warp timer. Signed-off-by: Clement Deschamps <clement.deschamps@greensocs.com> Message-Id: <20181021142103.19014-1-clement.deschamps@greensocs.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/cpus.c b/cpus.c
index 3978f63d8f..a2b33ccb29 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1554,6 +1554,14 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
atomic_mb_set(&cpu->exit_request, 0);
}
+ if (use_icount && all_cpu_threads_idle()) {
+ /*
+ * When all cpus are sleeping (e.g in WFI), to avoid a deadlock
+ * in the main_loop, wake it up in order to start the warp timer.
+ */
+ qemu_notify_event();
+ }
+
qemu_tcg_rr_wait_io_event(cpu ? cpu : first_cpu);
deal_with_unplugged_cpus();
}