Skip to contentSkip to conversation

arm: fix handling of nr_cpus

PATCH New Mark Salter 2 participants 7 messages Oct 11, 2011 – Oct 20, 2011

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

The current code duplicates the setup of the cpu_possible bitmap in the platform smp_init_cpus() function. Unfortunately, all of those places have the same bug where the nr_cpus kernel parameter is ignored. This patch consolidates the duplicated code in one place and fixes it to honor the nr_cpus parameter. This is accomplished by having smp_init_cpus() return the platform specific number of cores so that the caller (setup_arch) can set up the cpu_possible bitmap correctly for all platforms.

---
 arch/arm/include/asm/smp.h                        |    5 ++-
 arch/arm/kernel/setup.c                           |   24 +++++++++++++++++++-
 arch/arm/mach-exynos4/platsmp.c                   |   24 ++------------------
 arch/arm/mach-msm/platsmp.c                       |   14 +++--------
 arch/arm/mach-omap2/omap-smp.c                    |   24 ++------------------
 arch/arm/mach-realview/platsmp.c                  |   23 ++-----------------
 arch/arm/mach-shmobile/platsmp.c                  |   10 ++------
 arch/arm/mach-tegra/platsmp.c                     |   19 ++--------------
 arch/arm/mach-ux500/platsmp.c                     |   23 ++-----------------
 arch/arm/mach-vexpress/ct-ca9x4.c                 |   11 +++------
 arch/arm/mach-vexpress/include/mach/motherboard.h |    2 +-
 arch/arm/mach-vexpress/platsmp.c                  |    8 +-----
 12 files changed, 54 insertions(+), 133 deletions(-)
arch/arm/include/asm/smp.h +3 -2
index e42d96a..e9c38a9 100644
@@ -33,9 +33,10 @@ extern void show_ipi_list(struct seq_file *, int);
 asmlinkage void do_IPI(int ipinr, struct pt_regs *regs);
 
 /*
- * Setup the set of possible CPUs (via set_cpu_possible)
+ * Early platform SMP init.
+ * Returns the number of cores.
  */
-extern void smp_init_cpus(void);
+extern int smp_init_cpus(void);
 
 
 /*
arch/arm/kernel/setup.c +22 -2
index e514c76..5df2722 100644
@@ -913,8 +913,28 @@ void __init setup_arch(char **cmdline_p)
 	unflatten_device_tree();
 
 #ifdef CONFIG_SMP
-	if (is_smp())
-		smp_init_cpus();
+	/*
+	 * Initialise the CPU possible map early - this describes the CPUs
+	 * which may be present or become present in the system.
+	 */
+	if (is_smp()) {
+		int i, ncores;
+
+		ncores = smp_init_cpus();
+
+		if (ncores > NR_CPUS) {
+			printk(KERN_WARNING
+			       "Number of cores (%d) greater than configured "
+			       "maximum of %d - clipping\n",
+			       ncores, NR_CPUS);
+			ncores = NR_CPUS;
+		}
+		if (ncores > nr_cpu_ids)
+			ncores = nr_cpu_ids;
+
+		for (i = 0; i < ncores; i++)
+			set_cpu_possible(i, true);
+	}
 #endif
 	reserve_crashkernel();
 
arch/arm/mach-exynos4/platsmp.c +3 -21
index df6ef1b..70b3e99 100644
@@ -180,31 +180,13 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return pen_release != -1 ? -ENOSYS : 0;
 }
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
 	void __iomem *scu_base = scu_base_addr();
-	unsigned int i, ncores;
-
-	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
-
-	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "EXYNOS4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
 
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_base ? scu_get_core_count(scu_base) : 1;
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-msm/platsmp.c +4 -10
index 1a1af9e..b59f8b5 100644
@@ -147,19 +147,13 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 }
 
 /*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system. The msm8x60
- * does not support the ARM SCU, so just set the possible cpu mask to
- * NR_CPUS.
+ * The msm8x60 does not support the ARM SCU, so just return NR_CPUS.
  */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = get_core_count();
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-
         set_smp_cross_call(gic_raise_softirq);
+
+	return get_core_count();
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-omap2/omap-smp.c +3 -21
index ce65e93..deaf25a 100644
@@ -94,33 +94,15 @@ static void __init wakeup_secondary(void)
 	mb();
 }
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
-	unsigned int i, ncores;
-
 	/* Never released */
 	scu_base = ioremap(OMAP44XX_SCU_BASE, SZ_256);
 	BUG_ON(!scu_base);
 
-	ncores = scu_get_core_count(scu_base);
-
-	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "OMAP4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_get_core_count(scu_base);
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-realview/platsmp.c +3 -20
index 4ae943b..b6309c0 100644
@@ -40,30 +40,13 @@ static void __iomem *scu_base_addr(void)
 		return (void __iomem *)0;
 }
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
 	void __iomem *scu_base = scu_base_addr();
-	unsigned int i, ncores;
-
-	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
-
-	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "Realview: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
 
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_base ? scu_get_core_count(scu_base) : 1;
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-shmobile/platsmp.c +3 -7
index 66f9806..b9338e8 100644
@@ -51,15 +51,11 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return -ENOSYS;
 }
 
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
-	unsigned int ncores = shmobile_smp_get_core_count();
-	unsigned int i;
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-
 	set_smp_cross_call(gic_raise_softirq);
+
+	return shmobile_smp_get_core_count();
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-tegra/platsmp.c +3 -16
index 0886cbc..bcd8f72 100644
@@ -106,24 +106,11 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = scu_get_core_count(scu_base);
-
-	if (ncores > NR_CPUS) {
-		printk(KERN_ERR "Tegra: no. of cores (%u) greater than configured (%u), clipping\n",
-			ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_get_core_count(scu_base);
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-ux500/platsmp.c +3 -20
index a33df5f..c3491af 100644
@@ -144,30 +144,13 @@ static void __init wakeup_secondary(void)
 	mb();
 }
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
 	void __iomem *scu_base = scu_base_addr();
-	unsigned int i, ncores;
-
-	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
-
-	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "U8500: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
 
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_base ? scu_get_core_count(scu_base) : 1;
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
arch/arm/mach-vexpress/ct-ca9x4.c +4 -7
index bfd32f5..21006af 100644
@@ -217,14 +217,11 @@ static void __init ct_ca9x4_init(void)
 }
 
 #ifdef CONFIG_SMP
-static void ct_ca9x4_init_cpu_map(void)
+static int ct_ca9x4_smp_init_cpus(void)
 {
-	int i, ncores = scu_get_core_count(MMIO_P2V(A9_MPCORE_SCU));
-
-	for (i = 0; i < ncores; ++i)
-		set_cpu_possible(i, true);
-
 	set_smp_cross_call(gic_raise_softirq);
+
+	return scu_get_core_count(MMIO_P2V(A9_MPCORE_SCU));
 }
 
 static void ct_ca9x4_smp_enable(unsigned int max_cpus)
@@ -241,7 +238,7 @@ struct ct_desc ct_ca9x4_desc __initdata = {
 	.init_irq	= ct_ca9x4_init_irq,
 	.init_tile	= ct_ca9x4_init,
 #ifdef CONFIG_SMP
-	.init_cpu_map	= ct_ca9x4_init_cpu_map,
+	.smp_init_cpus	= ct_ca9x4_smp_init_cpus,
 	.smp_enable	= ct_ca9x4_smp_enable,
 #endif
 };
arch/arm/mach-vexpress/include/mach/motherboard.h +1 -1
index 0a3a375..2920ac7 100644
@@ -133,7 +133,7 @@ struct ct_desc {
 	void			(*init_irq)(void);
 	void			(*init_tile)(void);
 #ifdef CONFIG_SMP
-	void			(*init_cpu_map)(void);
+	int			(*smp_init_cpus)(void);
 	void			(*smp_enable)(unsigned int);
 #endif
 };
arch/arm/mach-vexpress/platsmp.c +2 -6
index 2b5f7ac..e713c7e 100644
@@ -22,13 +22,9 @@
 
 extern void versatile_secondary_startup(void);
 
-/*
- * Initialise the CPU possible map early - this describes the CPUs
- * which may be present or become present in the system.
- */
-void __init smp_init_cpus(void)
+int __init smp_init_cpus(void)
 {
-	ct_desc->init_cpu_map();
+	return ct_desc->smp_init_cpus();
 }
 
 void __init platform_smp_prepare_cpus(unsigned int max_cpus)
Signature · 1 line
1.7.6.4
#1 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 7 lines · Mark Salter

The current code duplicates the setup of the cpu_possible bitmap in the platform smp_init_cpus() function. Unfortunately, all of those places have the same bug where the nr_cpus kernel parameter is ignored. This patch consolidates the duplicated code in one place and fixes it to honor the nr_cpus parameter. This is accomplished by having smp_init_cpus() return the platform specific number of cores so that the caller (setup_arch) can set up the cpu_possible bitmap correctly for all platforms.

Who says every platform we're going to see will always have CPUs 0..N ? It's entirely possible that someone might want to have CPUs 0, 2, 3 as possible CPUs but omit CPU1 for platform reasons.

#2 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Mark Salter

The current code duplicates the setup of the cpu_possible bitmap in the platform smp_init_cpus() function. Unfortunately, all of those places have the same bug where the nr_cpus kernel parameter is ignored. This patch consolidates the duplicated code in one place and fixes it to honor the nr_cpus parameter. This is accomplished by having smp_init_cpus() return the platform specific number of cores so that the caller (setup_arch) can set up the cpu_possible bitmap correctly for all platforms.

Quoted 3 lines

Who says every platform we're going to see will always have CPUs 0..N ? It's entirely possible that someone might want to have CPUs 0, 2, 3 as possible CPUs but omit CPU1 for platform reasons.

Good point. We could do that by not setting the cpu_present bit for the CPU we want to omit. Or we could leave the current platform cpu_possible setup as-is and add something like:

   for (i = nr_cpu_ids; i < NR_CPUS; i++)
       set_cpu_possible(i, false);

to setup_arch after the call to smp_init_cpus.

--Mark

#3 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 14 lines · Mark Salter
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines · Mark Salter

The current code duplicates the setup of the cpu_possible bitmap in the platform smp_init_cpus() function. Unfortunately, all of those places have the same bug where the nr_cpus kernel parameter is ignored. This patch consolidates the duplicated code in one place and fixes it to honor the nr_cpus parameter. This is accomplished by having smp_init_cpus() return the platform specific number of cores so that the caller (setup_arch) can set up the cpu_possible bitmap correctly for all platforms.

Quoted 3 lines

Who says every platform we're going to see will always have CPUs 0..N ? It's entirely possible that someone might want to have CPUs 0, 2, 3 as possible CPUs but omit CPU1 for platform reasons.

Quoted 8 lines

Good point. We could do that by not setting the cpu_present bit for the CPU we want to omit. Or we could leave the current platform cpu_possible setup as-is and add something like:

   for (i = nr_cpu_ids; i < NR_CPUS; i++)
       set_cpu_possible(i, false);

to setup_arch after the call to smp_init_cpus.

As long as the mask bitmaps remain allocated above nr_cpu_ids, then yes. If that changes in generic code, I suspect this kind of thing may be missed.

I still wonder if doing this wouldn't be easier though - it results in a consistent message across all platforms, which is important if we're going to be checking against a user-passed value.

 arch/arm/mach-exynos4/platsmp.c  |   10 ++++------
 arch/arm/mach-omap2/omap-smp.c   |   10 ++++------
 arch/arm/mach-realview/platsmp.c |   10 ++++------
 arch/arm/mach-tegra/platsmp.c    |    8 ++++----
 arch/arm/mach-ux500/platsmp.c    |   10 ++++------
 5 files changed, 20 insertions(+), 28 deletions(-)
arch/arm/mach-exynos4/platsmp.c +4 -6
index df6ef1b..7381f56 100644
@@ -193,12 +193,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "EXYNOS4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("EXYNOS4: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-omap2/omap-smp.c +4 -6
index ce65e93..ec95516 100644
@@ -109,12 +109,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_get_core_count(scu_base);
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "OMAP4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("OMAP4: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-realview/platsmp.c +4 -6
index 4ae943b..4b33a72 100644
@@ -52,12 +52,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "Realview: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("Realview: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-tegra/platsmp.c +4 -4
index 0886cbc..f779d5e 100644
@@ -114,10 +114,10 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = scu_get_core_count(scu_base);
 
-	if (ncores > NR_CPUS) {
-		printk(KERN_ERR "Tegra: no. of cores (%u) greater than configured (%u), clipping\n",
-			ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("Tegra: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-ux500/platsmp.c +4 -6
index a33df5f..3af3e5c 100644
@@ -156,12 +156,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "U8500: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("U8500: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
#4 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 23 lines · Russell King - ARM Linux

I still wonder if doing this wouldn't be easier though - it results in a consistent message across all platforms, which is important if we're going to be checking against a user-passed value.

 arch/arm/mach-exynos4/platsmp.c  |   10 ++++------
 arch/arm/mach-omap2/omap-smp.c   |   10 ++++------
 arch/arm/mach-realview/platsmp.c |   10 ++++------
 arch/arm/mach-tegra/platsmp.c    |    8 ++++----
 arch/arm/mach-ux500/platsmp.c    |   10 ++++------
 5 files changed, 20 insertions(+), 28 deletions(-)
arch/arm/mach-exynos4/platsmp.c +0 -3
index df6ef1b..7381f56 100644
@@ -193,12 +193,10 @@ void __init smp_init_cpus(void)
        ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
        /* sanity check */
-       if (ncores > NR_CPUS) {
-               printk(KERN_WARNING
-                      "EXYNOS4: no. of cores (%d) greater than configured "

arch/arm/mach-exynos4/platsmp.c void __init smp_init_cpus(void) · line 202

Quoted 10 lines
arch/arm/mach-exynos4/platsmp.c +4 -3
-                      "maximum of %d - clipping\n",
-                      ncores, NR_CPUS);
-               ncores = NR_CPUS;
+       if (ncores > nr_cpu_ids) {
+               pr_warn("EXYNOS4: %u cores greater than maximum (%u), clipping\n",
+                       ncores, nr_cpu_ids);
+               ncores = nr_cpu_ids;
        }
 
        for (i = 0; i < ncores; i++)

...

That's fine by me. mach-msm, mach-shmobile, and mach-vexpress also need patching. They currently don't clip against NR_CPUS.

--Mark

#5 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 2 lines · Mark Salter

That's fine by me. mach-msm, mach-shmobile, and mach-vexpress also need patching. They currently don't clip against NR_CPUS.

So more like this then?

 arch/arm/mach-exynos4/platsmp.c   |   10 ++++------
 arch/arm/mach-msm/platsmp.c       |    6 ++++++
 arch/arm/mach-omap2/omap-smp.c    |   10 ++++------
 arch/arm/mach-realview/platsmp.c  |   10 ++++------
 arch/arm/mach-shmobile/platsmp.c  |    6 ++++++
 arch/arm/mach-tegra/platsmp.c     |    8 ++++----
 arch/arm/mach-ux500/platsmp.c     |   10 ++++------
 arch/arm/mach-vexpress/ct-ca9x4.c |    6 ++++++
 8 files changed, 38 insertions(+), 28 deletions(-)
arch/arm/mach-exynos4/platsmp.c +4 -6
index df6ef1b..7381f56 100644
@@ -193,12 +193,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "EXYNOS4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-msm/platsmp.c +6 -0
index 1a1af9e..7276595 100644
@@ -156,6 +156,12 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = get_core_count();
 
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
+	}
+
 	for (i = 0; i < ncores; i++)
 		set_cpu_possible(i, true);
 
arch/arm/mach-omap2/omap-smp.c +4 -6
index ce65e93..ec95516 100644
@@ -109,12 +109,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_get_core_count(scu_base);
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "OMAP4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-realview/platsmp.c +4 -6
index 4ae943b..4b33a72 100644
@@ -52,12 +52,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "Realview: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-shmobile/platsmp.c +6 -0
index 66f9806..e4e485f 100644
@@ -56,6 +56,12 @@ void __init smp_init_cpus(void)
 	unsigned int ncores = shmobile_smp_get_core_count();
 	unsigned int i;
 
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
+	}
+
 	for (i = 0; i < ncores; i++)
 		set_cpu_possible(i, true);
 
arch/arm/mach-tegra/platsmp.c +4 -4
index 0886cbc..f779d5e 100644
@@ -114,10 +114,10 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = scu_get_core_count(scu_base);
 
-	if (ncores > NR_CPUS) {
-		printk(KERN_ERR "Tegra: no. of cores (%u) greater than configured (%u), clipping\n",
-			ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-ux500/platsmp.c +4 -6
index a33df5f..3af3e5c 100644
@@ -156,12 +156,10 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "U8500: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
 	}
 
 	for (i = 0; i < ncores; i++)
arch/arm/mach-vexpress/ct-ca9x4.c +6 -0
index bfd32f5..2b1e836 100644
@@ -221,6 +221,12 @@ static void ct_ca9x4_init_cpu_map(void)
 {
 	int i, ncores = scu_get_core_count(MMIO_P2V(A9_MPCORE_SCU));
 
+	if (ncores > nr_cpu_ids) {
+		pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
+			ncores, nr_cpu_ids);
+		ncores = nr_cpu_ids;
+	}
+
 	for (i = 0; i < ncores; ++i)
 		set_cpu_possible(i, true);
 
#6 lore raw

PATCH 1/1 arm: fix handling of nr_cpus

Quoted 5 lines · Russell King - ARM Linux
Quoted 2 lines · Mark Salter

That's fine by me. mach-msm, mach-shmobile, and mach-vexpress also need patching. They currently don't clip against NR_CPUS.

So more like this then?

Yes. That works for me.

--Mark