Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1305618 > unrolled thread

[PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.

Started byAmeen <ameenali023@gmail.com>
First post2016-01-10 16:20 +0100
Last post2016-01-11 23:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS. Ameen <ameenali023@gmail.com> - 2016-01-10 16:20 +0100
    Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of  NR_CPUS. Vlastimil Babka <vbabka@suse.cz> - 2016-01-11 14:50 +0100
      Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of  NR_CPUS. Peter Zijlstra <peterz@infradead.org> - 2016-01-11 23:20 +0100

#1305618 — [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.

FromAmeen <ameenali023@gmail.com>
Date2016-01-10 16:20 +0100
Subject[PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
Message-ID<qPpWG-5U9-11@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1306219 — Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.

FromVlastimil Babka <vbabka@suse.cz>
Date2016-01-11 14:50 +0100
SubjectRe: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
Message-ID<qPL17-34y-15@gated-at.bofh.it>
In reply to#1305618
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)
> 

[toc] | [prev] | [next] | [standalone]


#1306770 — Re: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.

FromPeter Zijlstra <peterz@infradead.org>
Date2016-01-11 23:20 +0100
SubjectRe: [PATCH 2/2] Use num_possible_cpus() instead of direct use of NR_CPUS.
Message-ID<qPSYG-bV-13@gated-at.bofh.it>
In reply to#1306219
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web