qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [v2][PATCH 1/1] cpus: use cpu_is_stopped efficiently
@ 2013-08-02  1:43 Tiejun Chen
  2013-08-02 13:33 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Tiejun Chen @ 2013-08-02  1:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: mtosatti, afaerber

It makes more sense and simple later.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-05  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-02  1:43 [Qemu-devel] [v2][PATCH 1/1] cpus: use cpu_is_stopped efficiently Tiejun Chen
2013-08-02 13:33 ` Andreas Färber
2013-08-05  1:47   ` "“tiejun.chen”"

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).