x86: fix stack overflow for large values of MAX_APICS
authorJack Steiner <steiner@sgi.com>
Fri, 20 Jun 2008 02:51:05 +0000 (21:51 -0500)
committerIngo Molnar <mingo@elte.hu>
Tue, 8 Jul 2008 10:23:28 +0000 (12:23 +0200)
physid_mask_of_physid() causes a huge stack (12k) to be created if the
number of APICS is large. Replace physid_mask_of_physid() with a
new function that does not create large stacks. This is a problem only
on large x86_64 systems.

this paves the way to increase MAX_APICS.

Signed-off-by: Jack Steiner <steiner@sgi.com>
Cc: linux-mm@kvack.org
Cc: mingo@elte.hu
Cc: tglx@linutronix.de
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/apic_32.c
arch/x86/kernel/apic_64.c
arch/x86/kernel/smpboot.c
include/asm-x86/mpspec.h

index d5767cb19d565c421890273eabe465f7fa51505f..3f13a1aa07cdd433fe15260521fecfd6248915a6 100644 (file)
@@ -1269,7 +1269,7 @@ int __init APIC_init_uniprocessor(void)
 #ifdef CONFIG_CRASH_DUMP
        boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
 #endif
-       phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid);
+       physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
 
        setup_local_APIC();
 
index 0633cfd0dc291a1310f0632e1012cf663b5e89a9..5e22f8d2d5074147dd99aef5ba3cfbfbff29958b 100644 (file)
@@ -942,7 +942,7 @@ int __init APIC_init_uniprocessor(void)
 
        verify_local_APIC();
 
-       phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid);
+       physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
        apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
 
        setup_local_APIC();
index 3e1cecedde42747261c94053a53191ffa7291107..664a5db36d40f961ad3e5428c64b2dfbb1a6e47d 100644 (file)
@@ -1091,10 +1091,9 @@ static __init void disable_smp(void)
        smpboot_clear_io_apic_irqs();
 #endif
        if (smp_found_config)
-               phys_cpu_present_map =
-                               physid_mask_of_physid(boot_cpu_physical_apicid);
+               physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
        else
-               phys_cpu_present_map = physid_mask_of_physid(0);
+               physid_set_mask_of_physid(0, &phys_cpu_present_map);
        map_cpu_to_logical_apicid();
        cpu_set(0, per_cpu(cpu_sibling_map, 0));
        cpu_set(0, per_cpu(cpu_core_map, 0));
index 57a991b9c0530a0f82268853c74a6feb2411b883..b69e7ba7bf1d634dc3fe04c8794f3ea29e514979 100644 (file)
@@ -101,6 +101,7 @@ typedef struct physid_mask physid_mask_t;
                __physid_mask;                                          \
        })
 
+/* Note: will create very large stack frames if physid_mask_t is big */
 #define physid_mask_of_physid(physid)                                  \
        ({                                                              \
                physid_mask_t __physid_mask = PHYSID_MASK_NONE;         \
@@ -108,6 +109,12 @@ typedef struct physid_mask physid_mask_t;
                __physid_mask;                                          \
        })
 
+static inline void physid_set_mask_of_physid(int physid, physid_mask_t *map)
+{
+       physids_clear(*map);
+       physid_set(physid, *map);
+}
+
 #define PHYSID_MASK_ALL                { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
 #define PHYSID_MASK_NONE       { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }