From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J2xIk-0001TJ-Oc for qemu-devel@nongnu.org; Thu, 13 Dec 2007 18:17:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J2xIk-0001Ra-5s for qemu-devel@nongnu.org; Thu, 13 Dec 2007 18:17:10 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J2xIj-0001RK-RS for qemu-devel@nongnu.org; Thu, 13 Dec 2007 18:17:09 -0500 Received: from 0xc2c0b63d.fbbft3nxf1.bf-dhcp.tele.dk ([194.192.182.61] helo=smtp.hotelhot.dk) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J2xIj-0002K0-D2 for qemu-devel@nongnu.org; Thu, 13 Dec 2007 18:17:09 -0500 Received: from smtp.hotelhot.dk (localhost [127.0.0.1]) by smtp.hotelhot.dk (Postfix) with ESMTP id E5FF51409E for ; Fri, 14 Dec 2007 00:17:03 +0100 (CET) Received: from [192.168.0.251] (dhcp251.kalibalik.dk [192.168.0.251]) by smtp.hotelhot.dk (Postfix) with ESMTP id CA82B14093 for ; Fri, 14 Dec 2007 00:17:03 +0100 (CET) Message-ID: <4761BD6F.8030701@kalibalik.dk> Date: Fri, 14 Dec 2007 00:17:03 +0100 From: Anders Melchiorsen MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Reduce redundant timer rearming References: <4761BA27.5020307@flac.kalibalik.dk> In-Reply-To: <4761BA27.5020307@flac.kalibalik.dk> Content-Type: multipart/mixed; boundary="------------020005060707080108080206" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020005060707080108080206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > % 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. --------------020005060707080108080206 Content-Type: text/x-patch; name="qemu-rearm-when-modified.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-rearm-when-modified.diff" 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 --------------020005060707080108080206--