diff mbox

[v2,1/1] cpus: use cpu_is_stopped efficiently

Message ID 1375407789-5885-1-git-send-email-tiejun.chen@windriver.com
State New
Headers show

Commit Message

Tiejun Chen Aug. 2, 2013, 1:43 a.m. UTC
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(-)

Comments

Andreas Färber Aug. 2, 2013, 1:33 p.m. UTC | #1
Am 02.08.2013 03:43, schrieb Tiejun Chen:
> 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.

Patch doesn't apply to qemu.git: next_cpu and cpu_thread_is_idle() use
CPUState since a few weeks and do_vm_stop() changed from void to int.
Please remember to rebase before sending patches.

Thanks, applied to qom-cpu-next (with modified commit message):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next

Andreas
Tiejun Chen Aug. 5, 2013, 1:47 a.m. UTC | #2
On 08/02/2013 09:33 PM, � wrote:
> Am 02.08.2013 03:43, schrieb Tiejun Chen:
>> 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.
>
> Patch doesn't apply to qemu.git: next_cpu and cpu_thread_is_idle() use
> CPUState since a few weeks and do_vm_stop() changed from void to int.
> Please remember to rebase before sending patches.

Okay, sorry for this inconvenience.

Tiejun

>
> Thanks, applied to qom-cpu-next (with modified commit message):
> https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next
>
> Andreas
>
diff mbox

Patch

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;