From patchwork Fri Apr 20 05:32:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chubb X-Patchwork-Id: 153936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0609AB7041 for ; Fri, 20 Apr 2012 15:33:02 +1000 (EST) Received: from localhost ([::1]:46281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL6Sp-0005dc-KZ for incoming@patchwork.ozlabs.org; Fri, 20 Apr 2012 01:32:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL6Sf-0005d4-Tx for qemu-devel@nongnu.org; Fri, 20 Apr 2012 01:32:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SL6Sd-0000ze-DN for qemu-devel@nongnu.org; Fri, 20 Apr 2012 01:32:49 -0400 Received: from lemon.ertos.nicta.com.au ([203.143.174.143]:54740 helo=lemon.ken.nicta.com.au) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL6Sd-0000w1-25 for qemu-devel@nongnu.org; Fri, 20 Apr 2012 01:32:47 -0400 Received: from [2001:388:d000:800:224:d7ff:feaf:390] (port=60228 helo=Diprotodon.chubb.wattle.id.au) by lemon.ken.nicta.com.au with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1SL6SO-00044D-VY; Fri, 20 Apr 2012 15:32:36 +1000 Date: Fri, 20 Apr 2012 15:32:30 +1000 Message-ID: From: Peter Chubb To: Paolo Bonzini , qemu-devel@nongnu.org User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/23.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-Face: GgFg(Z>fx((4\32hvXq<)|jndSniCH~~$D)Ka:P@e@JR1P%Vr}EwUdfwf-4j\rUs#JR{'h# !]])6%Jh~b$VA|ALhnpPiHu[-x~@<"@Iv&|%R)Fq[[, (&Z'O)Q)xCqe1\M[F8#9l8~}#u$S$Rm`S9% \'T@`:&8>Sb*c5d'=eDYI&GF`+t[LfDH="MP5rwOO]w>ALi7'=QJHz&y&C&TE_3j! Organization: NICTA MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") X-SA-Exim-Connect-IP: 2001:388:d000:800:224:d7ff:feaf:390 X-SA-Exim-Mail-From: peter.chubb@nicta.com.au X-SA-Exim-Version: 4.2.1 (built Mon, 22 Mar 2010 06:52:44 +0000) X-SA-Exim-Scanned: Yes (on lemon.ken.nicta.com.au) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 203.143.174.143 Subject: [Qemu-devel] [PATCH] Limit ptimer rate to something achievable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If a guest sets very short timeouts, and asks for a timer to be reloaded on timeout, QEMU can go to 100%CPU utilisation and become unresponsive, as it is spending all its time generating timeout interrupts. On real hardware this doesn't matter, as the interrupts are just coalesced, and the effect is to have the interrupt asserted all the time. This patch is a band-aid, that prevents timeouts less than 10 microseconds from being set. 10 microseconds is a limit that was determined empirically on a variety of machines as the shortest that allowed QEMU to pick up a control-a c sequence to get at the monitor. Reported-by: Anna Lyons Signed-off-by: Peter Chubb --- hw/ptimer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- Dr Peter Chubb peter.chubb AT nicta.com.au http://www.ssrg.nicta.com.au Software Systems Research Group/NICTA Index: qemu-working/hw/ptimer.c =================================================================== --- qemu-working.orig/hw/ptimer.c 2012-04-20 15:09:09.317922659 +1000 +++ qemu-working/hw/ptimer.c 2012-04-20 15:30:42.108486207 +1000 @@ -180,6 +180,19 @@ void ptimer_set_freq(ptimer_state *s, ui count = limit. */ void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload) { + /* + * Artificially limit timeout rate to something + * achievable under QEMU. Otherwise, QEMU spends all + * its time generating timer interrupts, and there + * is no forward progress. + * About ten microseconds is the fastest that really works + * on the current generation of host machines. + */ + + if (limit * s->period < 10000 && s->period) { + limit = 10000 / s->period; + } + s->limit = limit; if (reload) s->delta = limit;