qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2] Reduce redundant timer rearming


From: Anders
Subject: Re: [Qemu-devel] [PATCH 2] Reduce redundant timer rearming
Date: Fri, 14 Dec 2007 00:29:50 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

(resending with the subscribed sender address)

> % time     seconds  usecs/call     calls    errors syscall
> ------ ----------- ----------- --------- --------- ----------------
>   99.74    0.012590           1     22766      2706 ioctl
>    0.26    0.000033           0     27044           clock_gettime
>    0.00    0.000000           0      5413           gettimeofday
>    0.00    0.000000           0      5745           select
>    0.00    0.000000           0      2706           rt_sigaction
>    0.00    0.000000           0      8119      5413 rt_sigtimedwait
>    0.00    0.000000           0      5215           timer_settime
>    0.00    0.000000           0      5413           timer_gettime
> ------ ----------- ----------- --------- --------- ----------------
> 100.00    0.012623                 82421      8119 total

Here is another patch that implements a dirty bit for the timer lists.
The bit is set when timers are modified or expire. Rearming clears the
bit (and only happens if it is set).

Numbers improve to this:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00    0.000013           0     21813           clock_gettime
  0.00    0.000000           0     22789      2729 ioctl
  0.00    0.000000           0      5459           gettimeofday
  0.00    0.000000           0      5790           select
  0.00    0.000000           0      2729           rt_sigaction
  0.00    0.000000           0      8188      5459 rt_sigtimedwait
  0.00    0.000000           0      2729           timer_settime
  0.00    0.000000           0      2752           timer_gettime
------ ----------- ----------- --------- --------- ----------------
100.00    0.000013                 72249      8188 total


I am not so sure about this one, so comments are appreciated.


Best regards,
Anders.


diff --git a/qemu/vl.c b/qemu/vl.c
index 2cd580d..924736e 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -816,6 +816,7 @@ struct qemu_alarm_timer {
 };
 
 #define ALARM_FLAG_DYNTICKS  0x1
+#define ALARM_FLAG_MODIFIED  0x2
 
 static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
 {
@@ -827,6 +828,11 @@ static void qemu_rearm_alarm_timer(struct qemu_alarm_timer 
*t)
     if (!alarm_has_dynticks(t))
         return;
 
+    if (!(t->flags & ALARM_FLAG_MODIFIED))
+        return;
+
+    t->flags &= ~(ALARM_FLAG_MODIFIED);
+
     t->rearm(t);
 }
 
@@ -989,6 +995,8 @@ void qemu_del_timer(QEMUTimer *ts)
 {
     QEMUTimer **pt, *t;
 
+    alarm_timer->flags |= ALARM_FLAG_MODIFIED;
+
     /* NOTE: this code must be signal safe because
        qemu_timer_expired() can be called from a signal. */
     pt = &active_timers[ts->clock->type];
@@ -1182,6 +1190,7 @@ static void host_alarm_handler(int host_signum)
 #endif
         CPUState *env = cpu_single_env;
         if (env) {
+            alarm_timer->flags |= ALARM_FLAG_MODIFIED;
             /* stop the currently executing cpu because a timer occured */
             cpu_interrupt(env, CPU_INTERRUPT_EXIT);
 #ifdef USE_KQEMU

reply via email to

[Prev in Thread] Current Thread [Next in Thread]