From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCVbN-0007Nd-2k for qemu-devel@nongnu.org; Tue, 27 Mar 2012 08:34:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCVbH-0003fY-Fo for qemu-devel@nongnu.org; Tue, 27 Mar 2012 08:34:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCVbH-0003fA-8Q for qemu-devel@nongnu.org; Tue, 27 Mar 2012 08:34:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2RCY9IN017861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 27 Mar 2012 08:34:09 -0400 Message-ID: <4F71B3BF.2060301@redhat.com> Date: Tue, 27 Mar 2012 14:34:07 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1332428393-4203-1-git-send-email-peter.portante@redhat.com> In-Reply-To: <1332428393-4203-1-git-send-email-peter.portante@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Small change to remove short 250us timeouts every other time through the wait loop. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Portante Cc: qemu-devel@nongnu.org, Peter Portante On 03/22/2012 04:59 PM, Peter Portante wrote: > Basically, the main wait loop calls qemu_run_all_timers() unconditionally. The > first thing this routine used to do is to see if a timer had been serviced, > and then reset the loop timeout to the next deadline. > > However, the new deadlines had not been calculated at that point, as > qemu_run_timers() had not been called yet for each of the clocks. So > qemu_rearm_alarm_timer() would end up with a negative or zero deadline, and > default to setting a 250us timeout for the loop. > > As qemu_run_timers() is called for each clock, the real deadlines would be put > in place, but because a loop timeout was already set, the loop timeout would > not be changed. > > Once that 250us timeout fired, the real deadline would be used for the > subsequent timeout. > > For idle VMs, this effectively doubles the number of times through the loop, > doubling the number of select() system calls, timer calls, etc. putting added > scheduling pressure on the kernel. And under cgroups, this really causes a big > problem because the cgroup code does not scale well. > > By simply running the timers before trying to rearm the timer, we always rearm > with a non-zero deadline, effectively halving the number of system calls. Reviewed-by: Avi Kivity Note the canonical subject line for patches is "subsystem: short description", in this case something like "qemu-timer: remove spurious host alarm wakeups" would be a good fit. -- error compiling committee.c: too many arguments to function