public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/deadline: Test for CPU's presence explicitly
@ 2014-02-17 14:12 Boris Ostrovsky
  2014-02-17 14:50 ` Peter Zijlstra
  2014-02-21 20:32 ` [tip:sched/urgent] sched/deadline: Test for CPU' s " tip-bot for Boris Ostrovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2014-02-17 14:12 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, konrad.wilk, boris.ostrovsky

A hot-removed CPU may have ID that is numerically larger than the number of
existing CPUs in the system (e.g. we can unplug CPU 4 from a system that
has CPUs 0, 1 and 4).

Thus the WARN_ONs should check whether the CPU in question is currently
present, not whether its ID value is less than num_present_cpus().

Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 kernel/sched/cpudeadline.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index 045fc74..5b8838b 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
 
 static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
 {
-	WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID);
+	WARN_ON(!cpu_present(idx) || idx == IDX_INVALID);
 
 	if (dl_time_before(new_dl, cp->elements[idx].dl)) {
 		cp->elements[idx].dl = new_dl;
@@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
 	}
 
 out:
-	WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1);
+	WARN_ON(!cpu_present(best_cpu) && best_cpu != -1);
 
 	return best_cpu;
 }
@@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
 	int old_idx, new_cpu;
 	unsigned long flags;
 
-	WARN_ON(cpu > num_present_cpus());
+	WARN_ON(!cpu_present(cpu));
 
 	raw_spin_lock_irqsave(&cp->lock, flags);
 	old_idx = cp->cpu_to_idx[cpu];
-- 
1.8.1.4


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

* Re: [PATCH] sched/deadline: Test for CPU's presence explicitly
  2014-02-17 14:12 [PATCH] sched/deadline: Test for CPU's presence explicitly Boris Ostrovsky
@ 2014-02-17 14:50 ` Peter Zijlstra
  2014-02-17 15:49   ` Juri Lelli
  2014-02-21 20:32 ` [tip:sched/urgent] sched/deadline: Test for CPU' s " tip-bot for Boris Ostrovsky
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2014-02-17 14:50 UTC (permalink / raw)
  To: Boris Ostrovsky; +Cc: mingo, linux-kernel, konrad.wilk, juri.lelli

On Mon, Feb 17, 2014 at 09:12:33AM -0500, Boris Ostrovsky wrote:
> A hot-removed CPU may have ID that is numerically larger than the number of
> existing CPUs in the system (e.g. we can unplug CPU 4 from a system that
> has CPUs 0, 1 and 4).
> 
> Thus the WARN_ONs should check whether the CPU in question is currently
> present, not whether its ID value is less than num_present_cpus().
> 
> Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Thanks!, please also always CC the author of the code in question.

> ---
>  kernel/sched/cpudeadline.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
> index 045fc74..5b8838b 100644
> --- a/kernel/sched/cpudeadline.c
> +++ b/kernel/sched/cpudeadline.c
> @@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
>  
>  static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
>  {
> -	WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID);
> +	WARN_ON(!cpu_present(idx) || idx == IDX_INVALID);
>  
>  	if (dl_time_before(new_dl, cp->elements[idx].dl)) {
>  		cp->elements[idx].dl = new_dl;
> @@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
>  	}
>  
>  out:
> -	WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1);
> +	WARN_ON(!cpu_present(best_cpu) && best_cpu != -1);
>  
>  	return best_cpu;
>  }
> @@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
>  	int old_idx, new_cpu;
>  	unsigned long flags;
>  
> -	WARN_ON(cpu > num_present_cpus());
> +	WARN_ON(!cpu_present(cpu));
>  
>  	raw_spin_lock_irqsave(&cp->lock, flags);
>  	old_idx = cp->cpu_to_idx[cpu];
> -- 
> 1.8.1.4
> 

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

* Re: [PATCH] sched/deadline: Test for CPU's presence explicitly
  2014-02-17 14:50 ` Peter Zijlstra
@ 2014-02-17 15:49   ` Juri Lelli
  0 siblings, 0 replies; 4+ messages in thread
From: Juri Lelli @ 2014-02-17 15:49 UTC (permalink / raw)
  To: Peter Zijlstra, Boris Ostrovsky; +Cc: mingo, linux-kernel, konrad.wilk

On 02/17/2014 03:50 PM, Peter Zijlstra wrote:
> On Mon, Feb 17, 2014 at 09:12:33AM -0500, Boris Ostrovsky wrote:
>> A hot-removed CPU may have ID that is numerically larger than the number of
>> existing CPUs in the system (e.g. we can unplug CPU 4 from a system that
>> has CPUs 0, 1 and 4).
>>
>> Thus the WARN_ONs should check whether the CPU in question is currently
>> present, not whether its ID value is less than num_present_cpus().
>>
>> Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
> Thanks!, please also always CC the author of the code in question.
>

Thanks!

- Juri

>> ---
>>  kernel/sched/cpudeadline.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
>> index 045fc74..5b8838b 100644
>> --- a/kernel/sched/cpudeadline.c
>> +++ b/kernel/sched/cpudeadline.c
>> @@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
>>  
>>  static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
>>  {
>> -	WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID);
>> +	WARN_ON(!cpu_present(idx) || idx == IDX_INVALID);
>>  
>>  	if (dl_time_before(new_dl, cp->elements[idx].dl)) {
>>  		cp->elements[idx].dl = new_dl;
>> @@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
>>  	}
>>  
>>  out:
>> -	WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1);
>> +	WARN_ON(!cpu_present(best_cpu) && best_cpu != -1);
>>  
>>  	return best_cpu;
>>  }
>> @@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
>>  	int old_idx, new_cpu;
>>  	unsigned long flags;
>>  
>> -	WARN_ON(cpu > num_present_cpus());
>> +	WARN_ON(!cpu_present(cpu));
>>  
>>  	raw_spin_lock_irqsave(&cp->lock, flags);
>>  	old_idx = cp->cpu_to_idx[cpu];
>> -- 
>> 1.8.1.4
>>

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

* [tip:sched/urgent] sched/deadline: Test for CPU' s presence explicitly
  2014-02-17 14:12 [PATCH] sched/deadline: Test for CPU's presence explicitly Boris Ostrovsky
  2014-02-17 14:50 ` Peter Zijlstra
@ 2014-02-21 20:32 ` tip-bot for Boris Ostrovsky
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Boris Ostrovsky @ 2014-02-21 20:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, konrad.wilk, boris.ostrovsky, peterz,
	rostedt, tglx, juri.lelli

Commit-ID:  82b95800b256205cff2eeab5bbd03430d2d0f20d
Gitweb:     http://git.kernel.org/tip/82b95800b256205cff2eeab5bbd03430d2d0f20d
Author:     Boris Ostrovsky <boris.ostrovsky@oracle.com>
AuthorDate: Mon, 17 Feb 2014 09:12:33 -0500
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:27:10 +0100

sched/deadline: Test for CPU's presence explicitly

A hot-removed CPU may have ID that is numerically larger than the number of
existing CPUs in the system (e.g. we can unplug CPU 4 from a system that
has CPUs 0, 1 and 4).

Thus the WARN_ONs should check whether the CPU in question is currently
present, not whether its ID value is less than num_present_cpus().

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1392646353-1874-1-git-send-email-boris.ostrovsky@oracle.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sched/cpudeadline.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index 045fc74..5b8838b 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
 
 static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
 {
-	WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID);
+	WARN_ON(!cpu_present(idx) || idx == IDX_INVALID);
 
 	if (dl_time_before(new_dl, cp->elements[idx].dl)) {
 		cp->elements[idx].dl = new_dl;
@@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
 	}
 
 out:
-	WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1);
+	WARN_ON(!cpu_present(best_cpu) && best_cpu != -1);
 
 	return best_cpu;
 }
@@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
 	int old_idx, new_cpu;
 	unsigned long flags;
 
-	WARN_ON(cpu > num_present_cpus());
+	WARN_ON(!cpu_present(cpu));
 
 	raw_spin_lock_irqsave(&cp->lock, flags);
 	old_idx = cp->cpu_to_idx[cpu];

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

end of thread, other threads:[~2014-02-21 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-17 14:12 [PATCH] sched/deadline: Test for CPU's presence explicitly Boris Ostrovsky
2014-02-17 14:50 ` Peter Zijlstra
2014-02-17 15:49   ` Juri Lelli
2014-02-21 20:32 ` [tip:sched/urgent] sched/deadline: Test for CPU' s " tip-bot for Boris Ostrovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox