From patchwork Mon Feb 14 15:22:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 83129 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 B88A6B7170 for ; Tue, 15 Feb 2011 03:42:04 +1100 (EST) Received: from localhost ([127.0.0.1]:40503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pp0cn-0002Ve-Rx for incoming@patchwork.ozlabs.org; Mon, 14 Feb 2011 10:46:05 -0500 Received: from [140.186.70.92] (port=57847 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pp0IO-0000CM-4A for qemu-devel@nongnu.org; Mon, 14 Feb 2011 10:25:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pp0IK-0003yj-2d for qemu-devel@nongnu.org; Mon, 14 Feb 2011 10:24:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pp0IJ-0003xO-Mw for qemu-devel@nongnu.org; Mon, 14 Feb 2011 10:24:55 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1EFOr7I024029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Feb 2011 10:24:54 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1EFOreD026362; Mon, 14 Feb 2011 10:24:53 -0500 Received: from amt.cnet (vpn-11-144.rdu.redhat.com [10.11.11.144]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p1EFOpID006222; Mon, 14 Feb 2011 10:24:51 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id CFB7F6520B8; Mon, 14 Feb 2011 13:23:31 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p1EFNT1p031961; Mon, 14 Feb 2011 13:23:29 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Mon, 14 Feb 2011 13:22:35 -0200 Message-Id: <46481d3921b86ef5ded7be7b5ce8194608f30e6b.1297696986.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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 06/37] Flatten the main loop 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 First of all, vm_can_run is a misnomer, it actually means "no request pending". Moreover, there is no need to check all pending requests twice, the first time via the inner loop check and then again when actually processing the requests. We can simply remove the inner loop and do the checks directly. Signed-off-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- vl.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/vl.c b/vl.c index 9c628f0..c9fa266 100644 --- a/vl.c +++ b/vl.c @@ -1389,14 +1389,16 @@ void main_loop_wait(int nonblocking) } -static int vm_can_run(void) +#ifndef CONFIG_IOTHREAD +static int vm_request_pending(void) { - return !(powerdown_requested || - reset_requested || - shutdown_requested || - debug_requested || - vmstop_requested); + return powerdown_requested || + reset_requested || + shutdown_requested || + debug_requested || + vmstop_requested; } +#endif qemu_irq qemu_system_powerdown; @@ -1411,21 +1413,19 @@ static void main_loop(void) qemu_main_loop_start(); for (;;) { - do { #ifndef CONFIG_IOTHREAD - nonblocking = cpu_exec_all(); - if (!vm_can_run()) { - nonblocking = true; - } + nonblocking = cpu_exec_all(); + if (vm_request_pending()) { + nonblocking = true; + } #endif #ifdef CONFIG_PROFILER - ti = profile_getclock(); + ti = profile_getclock(); #endif - main_loop_wait(nonblocking); + main_loop_wait(nonblocking); #ifdef CONFIG_PROFILER - dev_time += profile_getclock() - ti; + dev_time += profile_getclock() - ti; #endif - } while (vm_can_run()); if ((r = qemu_debug_requested())) { vm_stop(r);