qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] Correct alarm deadline computation
@ 2011-01-29 11:00 Paolo Bonzini
  2011-01-29 11:00 ` [Qemu-devel] [PATCH 2/2] Unify " Paolo Bonzini
  2011-01-30 16:46 ` [Qemu-devel] [PATCH 1/2] Correct " Aurelien Jarno
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2011-01-29 11:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jan Kiszka

When the QEMU_CLOCK_HOST clock was added, computation of its
deadline was added to qemu_next_deadline, which is correct but
incomplete.

I noticed this while trying to make sense of the rules whereby
qemu_next_deadline_dyntick is computed, which miss QEMU_CLOCK_HOST
when use_icount is true.  Looking at the history showed this to
be just an oversight, as the next patch shows clearly.

This patch inlines qemu_next_deadline into qemu_next_deadline_dyntick,
and corrects the logic so that only QEMU_CLOCK_VIRTUAL is skipped for
use_icount == true.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
---
 qemu-timer.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/qemu-timer.c b/qemu-timer.c
index db1ec49..174fd0c 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -724,11 +724,18 @@ static uint64_t qemu_next_deadline_dyntick(void)
     int64_t delta;
     int64_t rtdelta;
 
-    if (use_icount)
+    if (!use_icount && active_timers[QEMU_CLOCK_VIRTUAL]) {
+        delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time -
+                     qemu_get_clock(vm_clock);
+    } else {
         delta = INT32_MAX;
-    else
-        delta = (qemu_next_deadline() + 999) / 1000;
-
+    }
+    if (active_timers[QEMU_CLOCK_HOST]) {
+        int64_t hdelta = active_timers[QEMU_CLOCK_HOST]->expire_time -
+                 qemu_get_clock(host_clock);
+        if (hdelta < delta)
+            delta = hdelta;
+    }
     if (active_timers[QEMU_CLOCK_REALTIME]) {
         rtdelta = (active_timers[QEMU_CLOCK_REALTIME]->expire_time -
                  qemu_get_clock(rt_clock))*1000;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-30 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-29 11:00 [Qemu-devel] [PATCH 1/2] Correct alarm deadline computation Paolo Bonzini
2011-01-29 11:00 ` [Qemu-devel] [PATCH 2/2] Unify " Paolo Bonzini
2011-01-30 16:46 ` [Qemu-devel] [PATCH 1/2] Correct " Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).