[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 2/3] icount: sync vm_clock on the next event.
From: |
fred . konrad |
Subject: |
[Qemu-devel] [RFC 2/3] icount: sync vm_clock on the next event. |
Date: |
Thu, 18 Jul 2013 17:02:36 +0200 |
From: KONRAD Frederic <address@hidden>
We don't want vm_clock to be synchronized with rt_clock as it is
not deterministic for replay.
Signed-off-by: KONRAD Frederic <address@hidden>
---
cpus.c | 11 +++++++++--
main-loop.c | 5 +++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/cpus.c b/cpus.c
index 46504d0..fb83153 100644
--- a/cpus.c
+++ b/cpus.c
@@ -64,6 +64,8 @@
static CPUArchState *next_cpu;
+void icount_warp_rt(void *opaque);
+
static bool cpu_thread_is_idle(CPUState *cpu)
{
if (cpu->stop || cpu->queued_work_first) {
@@ -277,7 +279,7 @@ static int64_t qemu_icount_round(int64_t count)
return (count + (1 << icount_time_shift) - 1) >> icount_time_shift;
}
-static void icount_warp_rt(void *opaque)
+void icount_warp_rt(void *opaque)
{
if (vm_clock_warp_start == -1) {
return;
@@ -286,8 +288,13 @@ static void icount_warp_rt(void *opaque)
if (runstate_is_running()) {
int64_t clock = qemu_get_clock_ns(rt_clock);
int64_t warp_delta = clock - vm_clock_warp_start;
+ int64_t next_vm_deadline = qemu_clock_deadline(vm_clock);
if (use_icount == 1) {
- qemu_icount_bias += warp_delta;
+ if (next_vm_deadline > 0) {
+ qemu_icount_bias += next_vm_deadline;
+ } else {
+ qemu_notify_event();
+ }
} else {
/*
* In adaptive mode, do not let the vm_clock run too
diff --git a/main-loop.c b/main-loop.c
index a44fff6..16c9b85 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -33,6 +33,8 @@
#include "qemu/compatfd.h"
+void icount_warp_rt(void *opaque);
+
/* If we have signalfd, we mask out the signals we want to handle and then
* use signalfd to listen for them. We rely on whatever the current signal
* handler is to dispatch the signals when we receive them.
@@ -470,6 +472,9 @@ int main_loop_wait(int nonblocking)
qemu_run_all_timers();
+ if (use_icount == 1) {
+ icount_warp_rt(NULL);
+ }
return ret;
}
--
1.8.1.4