All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
@ 2016-01-10 15:13 Ameen
  2016-01-11 13:46 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: Ameen @ 2016-01-10 15:13 UTC (permalink / raw)
  To: mingo, peterz, mhocko, vbabka; +Cc: linux-kernel, Ameen

WARNING: usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus()..

Signed-off-by : Ameen Ali <Ameenali023@gmail.com>
---
 kernel/smp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/smp.c b/kernel/smp.c
index d903c02..94033ac 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -549,13 +549,13 @@ static int __init maxcpus(char *str)
 early_param("maxcpus", maxcpus);
 
 /* Setup number of possible processor ids */
-int nr_cpu_ids __read_mostly = NR_CPUS;
+int nr_cpu_ids __read_mostly = num_possible_cpus();
 EXPORT_SYMBOL(nr_cpu_ids);
 
 /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
 void __init setup_nr_cpu_ids(void)
 {
-	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
+	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),num_possible_cpus()) + 1;
 }
 
 void __weak smp_announce(void)
-- 
2.5.0

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

* Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
  2016-01-10 15:13 [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS Ameen
@ 2016-01-11 13:46 ` Vlastimil Babka
  2016-01-11 22:14   ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2016-01-11 13:46 UTC (permalink / raw)
  To: Ameen, mingo, peterz, mhocko; +Cc: linux-kernel

On 01/10/2016 04:13 PM, Ameen wrote:
> WARNING: usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus()..

Is that a checkpatch warning? Notice the word "often". You need to provide info
why it's the case here (and I doubt the change will be corect in this case).

> Signed-off-by : Ameen Ali <Ameenali023@gmail.com>
> ---
>  kernel/smp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/smp.c b/kernel/smp.c
> index d903c02..94033ac 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -549,13 +549,13 @@ static int __init maxcpus(char *str)
>  early_param("maxcpus", maxcpus);
>  
>  /* Setup number of possible processor ids */
> -int nr_cpu_ids __read_mostly = NR_CPUS;
> +int nr_cpu_ids __read_mostly = num_possible_cpus();
>  EXPORT_SYMBOL(nr_cpu_ids);
>  
>  /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
>  void __init setup_nr_cpu_ids(void)
>  {
> -	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
> +	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),num_possible_cpus()) + 1;
>  }
>  
>  void __weak smp_announce(void)
> 

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

* Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
  2016-01-11 13:46 ` Vlastimil Babka
@ 2016-01-11 22:14   ` Peter Zijlstra
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2016-01-11 22:14 UTC (permalink / raw)
  To: Vlastimil Babka; +Cc: Ameen, mingo, mhocko, linux-kernel

On Mon, Jan 11, 2016 at 02:46:22PM +0100, Vlastimil Babka wrote:
> On 01/10/2016 04:13 PM, Ameen wrote:
> > WARNING: usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus()..
> 
> Is that a checkpatch warning? Notice the word "often". You need to provide info
> why it's the case here (and I doubt the change will be corect in this case).

Yeah, this is terminally broken.

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

end of thread, other threads:[~2016-01-11 22:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-10 15:13 [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS Ameen
2016-01-11 13:46 ` Vlastimil Babka
2016-01-11 22:14   ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.