From patchwork Fri Feb 4 15:47:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 81905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AE19BB7112 for ; Sat, 5 Feb 2011 03:00:26 +1100 (EST) Received: from localhost ([127.0.0.1]:36736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlO59-0002Yx-30 for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 11:00:23 -0500 Received: from [140.186.70.92] (port=51755 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlNuw-00062d-CV for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlNuu-0007zq-0w for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlNut-0007z9-QE for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:47 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p14Fnlt5030601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Feb 2011 10:49:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p14Fnku8016911; Fri, 4 Feb 2011 10:49:46 -0500 Received: from amt.cnet (vpn2-8-97.ams2.redhat.com [10.36.8.97]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p14FnhrT002223; Fri, 4 Feb 2011 10:49:45 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 1F9E865202B; Fri, 4 Feb 2011 13:47:53 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p14Fln3G017671; Fri, 4 Feb 2011 13:47:49 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Fri, 4 Feb 2011 13:47:08 -0200 Message-Id: <42892f112c1bd31ed80fb5ae5cf84af6e3ed6331.1296834446.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 05/23] Leave inner main_loop faster on pending requests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka If there is any pending request that requires us to leave the inner loop if main_loop, makes sure we do this as soon as possible by enforcing non-blocking IO processing. At this change, move variable definitions out of the inner loop to improve readability. Signed-off-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- vl.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index 57b4c9f..6aa896c 100644 --- a/vl.c +++ b/vl.c @@ -1402,18 +1402,21 @@ qemu_irq qemu_system_powerdown; static void main_loop(void) { + bool nonblocking = false; +#ifdef CONFIG_PROFILER + int64_t ti; +#endif int r; qemu_main_loop_start(); for (;;) { do { - bool nonblocking = false; -#ifdef CONFIG_PROFILER - int64_t ti; -#endif #ifndef CONFIG_IOTHREAD nonblocking = cpu_exec_all(); + if (!vm_can_run()) { + nonblocking = true; + } #endif #ifdef CONFIG_PROFILER ti = profile_getclock();