[SPARC64]: Make cpu_present_map available earlier.
authorDavid S. Miller <davem@sunset.davemloft.net>
Sat, 25 Feb 2006 21:39:56 +0000 (13:39 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 27 Feb 2006 03:36:00 +0000 (19:36 -0800)
The change to kernel/sched.c's init code to use for_each_cpu()
requires that the cpu_possible_map be setup much earlier.

Set it up via setup_arch(), constrained to NR_CPUS, and later
constrain it to max_cpus in smp_prepare_cpus().

This fixes SMP booting on sparc64.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/setup.c
arch/sparc64/kernel/smp.c
include/asm-sparc64/smp.h

index 054461e6946d3334bfb0a3d56f878edfdae5c2b9..158bd31e15b790f255a81e2d23e024baf7157dca 100644 (file)
@@ -542,6 +542,8 @@ void __init setup_arch(char **cmdline_p)
        }
 #endif
 
+       smp_setup_cpu_possible_map();
+
        paging_init();
 }
 
index 1fb6323e65a4ec88ce0df377d7b1b770d1e856ed..1f7ad8a690526177bcfc62abe1c7a6f90c4f90b0 100644 (file)
@@ -1079,18 +1079,12 @@ int setup_profiling_timer(unsigned int multiplier)
        return 0;
 }
 
+/* Constrain the number of cpus to max_cpus.  */
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-       int instance, mid;
-
-       instance = 0;
-       while (!cpu_find_by_instance(instance, NULL, &mid)) {
-               if (mid < max_cpus)
-                       cpu_set(mid, phys_cpu_present_map);
-               instance++;
-       }
-
        if (num_possible_cpus() > max_cpus) {
+               int instance, mid;
+
                instance = 0;
                while (!cpu_find_by_instance(instance, NULL, &mid)) {
                        if (mid != boot_cpu_id) {
@@ -1105,6 +1099,22 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
        smp_store_cpu_info(boot_cpu_id);
 }
 
+/* Set this up early so that things like the scheduler can init
+ * properly.  We use the same cpu mask for both the present and
+ * possible cpu map.
+ */
+void __init smp_setup_cpu_possible_map(void)
+{
+       int instance, mid;
+
+       instance = 0;
+       while (!cpu_find_by_instance(instance, NULL, &mid)) {
+               if (mid < NR_CPUS)
+                       cpu_set(mid, phys_cpu_present_map);
+               instance++;
+       }
+}
+
 void __devinit smp_prepare_boot_cpu(void)
 {
        if (hard_smp_processor_id() >= NR_CPUS) {
index 110a2de891239407ff048772b920fa531119a7eb..473edb2603ecd46d0c14186fdacb4b544a5baba2 100644 (file)
@@ -66,8 +66,14 @@ static __inline__ int hard_smp_processor_id(void)
 
 #define raw_smp_processor_id() (current_thread_info()->cpu)
 
+extern void smp_setup_cpu_possible_map(void);
+
 #endif /* !(__ASSEMBLY__) */
 
+#else
+
+#define smp_setup_cpu_possible_map() do { } while (0)
+
 #endif /* !(CONFIG_SMP) */
 
 #define NO_PROC_ID             0xFF