From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V54Oo-00058f-8k for qemu-devel@nongnu.org; Thu, 01 Aug 2013 21:43:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V54Oh-0005YQ-Gh for qemu-devel@nongnu.org; Thu, 01 Aug 2013 21:43:22 -0400 Received: from mail1.windriver.com ([147.11.146.13]:49683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V54Oh-0005YB-8f for qemu-devel@nongnu.org; Thu, 01 Aug 2013 21:43:15 -0400 From: Tiejun Chen Date: Fri, 2 Aug 2013 09:43:09 +0800 Message-ID: <1375407789-5885-1-git-send-email-tiejun.chen@windriver.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [v2][PATCH 1/1] cpus: use cpu_is_stopped efficiently List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mtosatti@redhat.com, afaerber@suse.de It makes more sense and simple later. Signed-off-by: Tiejun Chen --- v1 -> v2: To optimize performance slightly, we can reorder the two conditions to avoid the non-inline function call if cpu->stopped. cpus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cpus.c b/cpus.c index c232265..7e76506 100644 --- a/cpus.c +++ b/cpus.c @@ -62,6 +62,11 @@ static CPUArchState *next_cpu; +bool cpu_is_stopped(CPUState *cpu) +{ + return cpu->stopped || !runstate_is_running(); +} + static bool cpu_thread_is_idle(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); @@ -69,7 +74,7 @@ static bool cpu_thread_is_idle(CPUArchState *env) if (cpu->stop || cpu->queued_work_first) { return false; } - if (cpu->stopped || !runstate_is_running()) { + if (cpu_is_stopped(cpu)) { return true; } if (!cpu->halted || qemu_cpu_has_work(cpu) || @@ -432,11 +437,6 @@ void cpu_synchronize_all_post_init(void) } } -bool cpu_is_stopped(CPUState *cpu) -{ - return !runstate_is_running() || cpu->stopped; -} - static void do_vm_stop(RunState state) { if (runstate_is_running()) { @@ -455,7 +455,7 @@ static bool cpu_can_run(CPUState *cpu) if (cpu->stop) { return false; } - if (cpu->stopped || !runstate_is_running()) { + if (cpu_is_stopped(cpu)) { return false; } return true; -- 1.7.9.5