qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently
@ 2013-07-26  8:47 Tiejun Chen
  2013-08-01  8:12 ` "“tiejun.chen”"
  2013-08-01 11:38 ` Andreas Färber
  0 siblings, 2 replies; 5+ messages in thread
From: Tiejun Chen @ 2013-07-26  8:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: mtosatti, avi

It makes more sense and simple later.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
 cpus.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/cpus.c b/cpus.c
index c232265..a997632 100644
--- a/cpus.c
+++ b/cpus.c
@@ -62,6 +62,11 @@
 
 static CPUArchState *next_cpu;
 
+bool cpu_is_stopped(CPUState *cpu)
+{
+    return !runstate_is_running() || cpu->stopped;
+}
+
 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] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently
  2013-07-26  8:47 [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently Tiejun Chen
@ 2013-08-01  8:12 ` "“tiejun.chen”"
  2013-08-01 16:26   ` Marcelo Tosatti
  2013-08-01 11:38 ` Andreas Färber
  1 sibling, 1 reply; 5+ messages in thread
From: "“tiejun.chen”" @ 2013-08-01  8:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: mtosatti, avi.kivity

On 07/26/2013 04:47 PM, Tiejun Chen wrote:
> It makes more sense and simple later.

Any feedback :)

Tiejun

>
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
> ---
>   cpus.c |   14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index c232265..a997632 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -62,6 +62,11 @@
>
>   static CPUArchState *next_cpu;
>
> +bool cpu_is_stopped(CPUState *cpu)
> +{
> +    return !runstate_is_running() || cpu->stopped;
> +}
> +
>   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;
>

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

* Re: [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently
  2013-07-26  8:47 [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently Tiejun Chen
  2013-08-01  8:12 ` "“tiejun.chen”"
@ 2013-08-01 11:38 ` Andreas Färber
  2013-08-02  1:45   ` "“tiejun.chen”"
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2013-08-01 11:38 UTC (permalink / raw)
  To: Tiejun Chen; +Cc: mtosatti, qemu-devel

Hi,

Am 26.07.2013 10:47, schrieb Tiejun Chen:
> It makes more sense and simple later.
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
> ---
>  cpus.c |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index c232265..a997632 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -62,6 +62,11 @@
>  
>  static CPUArchState *next_cpu;
>  
> +bool cpu_is_stopped(CPUState *cpu)
> +{
> +    return !runstate_is_running() || cpu->stopped;
> +}
> +
>  static bool cpu_thread_is_idle(CPUArchState *env)
>  {
>      CPUState *cpu = ENV_GET_CPU(env);

To optimize performance slightly, I would suggest to reorder the two
conditions as they were below (avoiding the non-inline function call if
cpu->stopped).

Other than that it looks good to me, but no bugfix for 1.6.
If you send a v2 I can queue it on qom-cpu for the next merge window in
two weeks.

CC'ing me would have made me review it earlier. ;) And as you may have
noticed, Avi is no longer with Red Hat, and Gleb and Paolo are
maintaining KVM parts, which there are none in this patch. See
MAINTAINERS file for the latest list.

Regards,
Andreas

> @@ -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;
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently
  2013-08-01  8:12 ` "“tiejun.chen”"
@ 2013-08-01 16:26   ` Marcelo Tosatti
  0 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2013-08-01 16:26 UTC (permalink / raw)
  To: "“tiejun.chen”"; +Cc: qemu-devel, avi.kivity

On Thu, Aug 01, 2013 at 04:12:03PM +0800, "“tiejun.chen”" wrote:
> On 07/26/2013 04:47 PM, Tiejun Chen wrote:
> >It makes more sense and simple later.
> 
> Any feedback :)
> 
> Tiejun

Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>

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

* Re: [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently
  2013-08-01 11:38 ` Andreas Färber
@ 2013-08-02  1:45   ` "“tiejun.chen”"
  0 siblings, 0 replies; 5+ messages in thread
From: "“tiejun.chen”" @ 2013-08-02  1:45 UTC (permalink / raw)
  To: Andreas Färber; +Cc: mtosatti, qemu-devel

On 08/01/2013 07:38 PM, � wrote:
> Hi,
>
> Am 26.07.2013 10:47, schrieb Tiejun Chen:
>> It makes more sense and simple later.
>>
>> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
>> ---
>>   cpus.c |   14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/cpus.c b/cpus.c
>> index c232265..a997632 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -62,6 +62,11 @@
>>
>>   static CPUArchState *next_cpu;
>>
>> +bool cpu_is_stopped(CPUState *cpu)
>> +{
>> +    return !runstate_is_running() || cpu->stopped;
>> +}
>> +
>>   static bool cpu_thread_is_idle(CPUArchState *env)
>>   {
>>       CPUState *cpu = ENV_GET_CPU(env);
>
> To optimize performance slightly, I would suggest to reorder the two
> conditions as they were below (avoiding the non-inline function call if
> cpu->stopped).

Good idea.

>
> Other than that it looks good to me, but no bugfix for 1.6.
> If you send a v2 I can queue it on qom-cpu for the next merge window in
> two weeks.

I already send this v2 just now.

>
> CC'ing me would have made me review it earlier. ;) And as you may have
> noticed, Avi is no longer with Red Hat, and Gleb and Paolo are
> maintaining KVM parts, which there are none in this patch. See
> MAINTAINERS file for the latest list.

Thanks for your information :)

Tiejun

>
> Regards,
> Andreas
>
>> @@ -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;
>>
>
>

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-26  8:47 [Qemu-devel] [PATCH] cpus: use cpu_is_stopped efficiently Tiejun Chen
2013-08-01  8:12 ` "“tiejun.chen”"
2013-08-01 16:26   ` Marcelo Tosatti
2013-08-01 11:38 ` Andreas Färber
2013-08-02  1:45   ` "“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).