cpumask: make nr_cpu_ids valid in all configurations.

nr_cpu_ids is the (badly named) runtime limit on possible CPU numbers;
ie. the variable version of NR_CPUS.

This makes is valid in all configs, including UP.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/cpumask.h |   10 ++++++++--
 init/main.c             |    7 +++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff -r b2e53a337c32 include/linux/cpumask.h
--- a/include/linux/cpumask.h	Sat Oct 04 21:02:43 2008 +1000
+++ b/include/linux/cpumask.h	Sat Oct 04 21:03:53 2008 +1000
@@ -189,6 +189,14 @@ extern cpumask_t _unused_cpumask_arg_;
 #define cpus_addr(src) ((src).bits)
 /* End deprecated region. */
 
+#if NR_CPUS <= BITS_PER_LONG
+/* Constant is usually more efficient than a variable for small NR_CPUS */
+#define nr_cpu_ids NR_CPUS
+#else
+/* Starts at NR_CPUS until we know better. */
+extern int nr_cpu_ids;
+#endif /* NR_CPUS > BITS_PER_LONG */
+
 #define cpumask_size() (BITS_TO_LONGS(NR_CPUS) * sizeof(long))
 
 static inline void cpumask_set_cpu(int cpu, volatile struct cpumask *dstp)
@@ -425,7 +433,6 @@ extern cpumask_t cpu_mask_all;
 
 #if NR_CPUS == 1
 
-#define nr_cpu_ids		1
 #define first_cpu(src)		({ (void)(src); 0; })
 #define next_cpu(n, src)	({ (void)(src); 1; })
 #define any_online_cpu(mask)	0
@@ -434,7 +441,6 @@ extern cpumask_t cpu_mask_all;
 
 #else /* NR_CPUS > 1 */
 
-extern int nr_cpu_ids;
 int __first_cpu(const cpumask_t *srcp);
 int __next_cpu(int n, const cpumask_t *srcp);
 int __any_online_cpu(const cpumask_t *mask);
diff -r b2e53a337c32 init/main.c
--- a/init/main.c	Sat Oct 04 21:02:43 2008 +1000
+++ b/init/main.c	Sat Oct 04 21:03:53 2008 +1000
@@ -370,6 +370,8 @@ EXPORT_SYMBOL(cpu_mask_all);
 #endif
 
 /* Setup number of possible processor ids */
+/* nr_cpu_ids is a real variable for large NR_CPUS. */
+#ifndef nr_cpu_ids
 int nr_cpu_ids __read_mostly = NR_CPUS;
 EXPORT_SYMBOL(nr_cpu_ids);
 
@@ -383,6 +385,11 @@ void __init setup_nr_cpu_ids(void)
 
 	nr_cpu_ids = highest_cpu + 1;
 }
+#else
+void __init setup_nr_cpu_ids(void)
+{
+}
+#endif /* ... nr_cpu_ids is a constant. */
 
 #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
