diff mbox series

[1/2] core: Fix iteration condition to skip garded cpu

Message ID 20180418153646.20623-1-svaidy@linux.vnet.ibm.com
State Accepted
Headers show
Series [1/2] core: Fix iteration condition to skip garded cpu | expand

Commit Message

Vaidyanathan Srinivasan April 18, 2018, 3:36 p.m. UTC
Fix the logic error in the loop that iterated incorrectly
over garded cpu.

Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---
 core/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nicholas Piggin April 18, 2018, 3:51 p.m. UTC | #1
On Wed, 18 Apr 2018 21:06:45 +0530
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> wrote:

> Fix the logic error in the loop that iterated incorrectly
> over garded cpu.
> 
> Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
> ---
>  core/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/core/cpu.c b/core/cpu.c
> index 6826fee0..369eb5b9 100644
> --- a/core/cpu.c
> +++ b/core/cpu.c
> @@ -734,7 +734,7 @@ struct cpu_thread *next_ungarded_primary(struct cpu_thread *cpu)
>  {
>  	do {
>  		cpu = next_cpu(cpu);
> -	} while(cpu && cpu->state == cpu_state_unavailable && cpu->primary != cpu);
> +	} while(cpu && (cpu->state == cpu_state_unavailable || cpu->primary != cpu));
>  
>  	return cpu;
>  }

Wow, good catch, thanks.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Stewart Smith April 19, 2018, 6:02 a.m. UTC | #2
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> writes:
> Fix the logic error in the loop that iterated incorrectly
> over garded cpu.
>
> Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
> ---
>  core/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Nice.

Series merged to master as of 2aa2616358e38a38032efeadcd17ef4cd91e088c
diff mbox series

Patch

diff --git a/core/cpu.c b/core/cpu.c
index 6826fee0..369eb5b9 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -734,7 +734,7 @@  struct cpu_thread *next_ungarded_primary(struct cpu_thread *cpu)
 {
 	do {
 		cpu = next_cpu(cpu);
-	} while(cpu && cpu->state == cpu_state_unavailable && cpu->primary != cpu);
+	} while(cpu && (cpu->state == cpu_state_unavailable || cpu->primary != cpu));
 
 	return cpu;
 }