Commit 62e6f1e8 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds
Browse files

fix maxcpus=1 oops in show_stat()

Alexey Dobriyan reports that maxcpus=1 is still broken in 2.6.23-rc4:
if CONFIG_HOTPLUG_CPU is not set, x86_64 bootup oopses in show_stat() -
for_each_possible_cpu accesses a per-cpu area which was never set up.

Alexey identified commit 61ec7567
(ACPI: boot correctly with "nosmp" or "maxcpus=0") as the origin;
but it's not really to blame, just exposes a bug in 2.6.23-rc1's commit

 (Especially when !CONFIG_HOTPLUG_CPU,
avoid needlessy allocating resources for CPUs that can never become available).

rc1's test for max_cpus < 2 in start_kernel() wasn't working because
max_cpus was still NR_CPUS at that point: until rc4 moved the maxcpus
parsing earlier.  Now it sets cpu_possible_map to 1 before allocating
all possible per-cpu areas; then smp_init() expands cpu_possible_map
to cpu_present_map (0xf in my case) later on.

rc1's commit has good intentions, but expects cpu_present_map to be
limited by maxcpus, which is only the case on i386.  cpus_and(possible,
possible,present) might be good, but needs an audit of cpu_present_map
uses - there may well be assumptions that any cpu present is possible.

So stay safe for now and just revert those #ifndef CONFIG_HOTPLUG_CPU
optimizations in rc1's commit.
Signed-off-by: default avatarHugh Dickins <>
Cc: Alexey Dobriyan <>
Cc: Len Brown <>
Cc: Andrew Morton <>
Cc: Jan Beulich <>
Signed-off-by: default avatarLinus Torvalds <>
parent a1c582d0
...@@ -397,10 +397,6 @@ static void __init smp_init(void) ...@@ -397,10 +397,6 @@ static void __init smp_init(void)
{ {
unsigned int cpu; unsigned int cpu;
cpu_possible_map = cpu_present_map;
/* FIXME: This should be done in userspace --RR */ /* FIXME: This should be done in userspace --RR */
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
if (num_online_cpus() >= max_cpus) if (num_online_cpus() >= max_cpus)
...@@ -545,10 +541,6 @@ asmlinkage void __init start_kernel(void) ...@@ -545,10 +541,6 @@ asmlinkage void __init start_kernel(void)
setup_arch(&command_line); setup_arch(&command_line);
setup_command_line(command_line); setup_command_line(command_line);
unwind_setup(); unwind_setup();
if (max_cpus < 2)
cpu_possible_map = cpu_online_map;
setup_per_cpu_areas(); setup_per_cpu_areas();
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
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