Skip to contentSkip to conversation

[5636] Run timers from host alarm timer callback

Qemu-devel Anthony Liguori 3 participants 7 messages Nov 5, 2008 – Nov 11, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5636

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5636
Author:   aliguori
Date:     2008-11-05 21:04:35 +0000 (Wed, 05 Nov 2008)

Log Message:
-----------
Run timers from host alarm timer callback

This further cleans up the main loop getting it a lot closer to what a main loop should be.

Modified Paths:
--------------
trunk/vl.c

Modified: trunk/vl.c
===================================================================

vl.c +9 -10
@@ -1700,6 +1700,15 @@
         len = read(alarm_timer_rfd, buffer, sizeof(buffer));
     } while ((len == -1 && errno == EINTR) || len > 0);
 
+    /* vm time timers */
+    if (vm_running && likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER)))
+        qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
+                        qemu_get_clock(vm_clock));
+
+    /* real time timers */
+    qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
+                    qemu_get_clock(rt_clock));
+
     if (t->flags & ALARM_FLAG_EXPIRED) {
         alarm_timer->flags &= ~ALARM_FLAG_EXPIRED;
         qemu_rearm_alarm_timer(alarm_timer);
@@ -4551,16 +4560,6 @@
     }
 #endif
 
-    if (vm_running) {
-        if (likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER)))
-        qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],
-                        qemu_get_clock(vm_clock));
-    }
-
-    /* real time timers */
-    qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
-                    qemu_get_clock(rt_clock));
-
     /* Check bottom-halves last in case any of the earlier events triggered
        them.  */
     qemu_bh_poll();
#1 lore raw
Quoted 5 lines · Anthony Liguori

Revision: 5636

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5636
Author:   aliguori
Date:     2008-11-05 21:04:35 +0000 (Wed, 05 Nov 2008)
Quoted 9 lines

Log Message:
-----------
Run timers from host alarm timer callback

This further cleans up the main loop getting it a lot closer to what a main loop should be.

I've tested this with a variety of clocks and guests but this could uncover more bugs like the previous 5s select sleep. If things start slowing down, please try this changeset first and let me know.

Regards,

Anthony Liguori

#2 lore raw

Hi,

This commit caused a noticeable slowdown while using the instruction counting mechanism. I'm testing with the sparc-test image and with --icount auto.

Any ideas?

Thanks,

Luís Pureza

Quoted 29 lines · Anthony Liguori
Quoted 10 lines · Anthony Liguori

Revision: 5636

         http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5636
Author:   aliguori
Date:     2008-11-05 21:04:35 +0000 (Wed, 05 Nov 2008)

Log Message:
-----------
Run timers from host alarm timer callback

Quoted 6 lines

This further cleans up the main loop getting it a lot closer to what a main
loop should be.

I've tested this with a variety of clocks and guests but this could uncover more bugs like the previous 5s select sleep. If things start slowing down, please try this changeset first and let me know.

Regards,

Anthony Liguori

#3 lore raw
Quoted 6 lines · Luis Pureza

Hi,

This commit caused a noticeable slowdown while using the instruction counting mechanism. I'm testing with the sparc-test image and with --icount auto.

Yeah, I take it that all timers don't result in signals when using icount and that we rely on select() timeout instead. Let me look a little more closely at the code and I'll come up with a fix.

Regards,

Anthony Liguori

Quoted 41 lines

Any ideas?

Thanks,

Luís Pureza

Quoted 30 lines · Anthony Liguori
Quoted 9 lines · Anthony Liguori

Revision: 5636

         http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5636
Author:   aliguori
Date:     2008-11-05 21:04:35 +0000 (Wed, 05 Nov 2008)

Log Message:
-----------
Run timers from host alarm timer callback

Quoted 7 lines

This further cleans up the main loop getting it a lot closer to what a main
loop should be.

I've tested this with a variety of clocks and guests but this could uncover more bugs like the previous 5s select sleep. If things start slowing down, please try this changeset first and let me know.

Regards,

Anthony Liguori

#4 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 5 lines · Luis Pureza

Hi,

This commit caused a noticeable slowdown while using the instruction counting mechanism. I'm testing with the sparc-test image and with --icount auto.

Yeah, I take it that all timers don't result in signals when using icount and that we rely on select() timeout instead. Let me look a little more closely at the code and I'll come up with a fix.

In icount mode vm_clock timers don't use host timers at all.

Instead we calculate how long we want to wait before checking again (the EXCP_HALT code in vl.c:main_loop), and use that as the select timeout.

Paul

#5 lore raw
In reply to Anthony Liguori
Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Luis Pureza

Hi,

This commit caused a noticeable slowdown while using the instruction counting mechanism. I'm testing with the sparc-test image and with --icount auto.

Yeah, I take it that all timers don't result in signals when using icount and that we rely on select() timeout instead. Let me look a little more closely at the code and I'll come up with a fix.

Did r5623 happen to fix this problem?

Regards,

Anthony Liguori

#6 lore raw
Quoted 2 lines · Anthony Liguori

Anthony Liguori wrote:
Did r5623 happen to fix this problem?

Sorry, no. Should it?

Luís Pureza