Commit b6df1b8b authored by Jack Steiner's avatar Jack Steiner Committed by Ingo Molnar

x86: fix stack overflow for large values of MAX_APICS

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: default avatarJack Steiner <steiner@sgi.com>
Cc: linux-mm@kvack.org
Cc: mingo@elte.hu
Cc: tglx@linutronix.de
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent d400524a
...@@ -1269,7 +1269,7 @@ int __init APIC_init_uniprocessor(void) ...@@ -1269,7 +1269,7 @@ int __init APIC_init_uniprocessor(void)
#ifdef CONFIG_CRASH_DUMP #ifdef CONFIG_CRASH_DUMP
boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
#endif #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(); setup_local_APIC();
......
...@@ -942,7 +942,7 @@ int __init APIC_init_uniprocessor(void) ...@@ -942,7 +942,7 @@ int __init APIC_init_uniprocessor(void)
verify_local_APIC(); 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)); apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
setup_local_APIC(); setup_local_APIC();
......
...@@ -1091,10 +1091,9 @@ static __init void disable_smp(void) ...@@ -1091,10 +1091,9 @@ static __init void disable_smp(void)
smpboot_clear_io_apic_irqs(); smpboot_clear_io_apic_irqs();
#endif #endif
if (smp_found_config) if (smp_found_config)
phys_cpu_present_map = physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
physid_mask_of_physid(boot_cpu_physical_apicid);
else 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(); map_cpu_to_logical_apicid();
cpu_set(0, per_cpu(cpu_sibling_map, 0)); cpu_set(0, per_cpu(cpu_sibling_map, 0));
cpu_set(0, per_cpu(cpu_core_map, 0)); cpu_set(0, per_cpu(cpu_core_map, 0));
......
...@@ -101,6 +101,7 @@ typedef struct physid_mask physid_mask_t; ...@@ -101,6 +101,7 @@ typedef struct physid_mask physid_mask_t;
__physid_mask; \ __physid_mask; \
}) })
/* Note: will create very large stack frames if physid_mask_t is big */
#define physid_mask_of_physid(physid) \ #define physid_mask_of_physid(physid) \
({ \ ({ \
physid_mask_t __physid_mask = PHYSID_MASK_NONE; \ physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
...@@ -108,6 +109,12 @@ typedef struct physid_mask physid_mask_t; ...@@ -108,6 +109,12 @@ typedef struct physid_mask physid_mask_t;
__physid_mask; \ __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_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} } #define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment