Commit 2b633e3fac5efada088b57d31e65401f22bcc18f
Committed by
H. Peter Anvin
1 parent
6738762d73
Exists in
master
and in
4 other branches
smp: Use nr_cpus= to set nr_cpu_ids early
On x86, before prefill_possible_map(), nr_cpu_ids will be NR_CPUS aka CONFIG_NR_CPUS. Add nr_cpus= to set nr_cpu_ids. so we can simulate cpus <=8 are installed on normal config. -v2: accordging to Christoph, acpi_numa_init should use nr_cpu_ids in stead of NR_CPUS. -v3: add doc in kernel-parameters.txt according to Andrew. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <1265793639-15071-34-git-send-email-yinghai@kernel.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Cc: Tony Luck <tony.luck@intel.com>
Showing 5 changed files with 28 additions and 7 deletions Side-by-side Diff
Documentation/kernel-parameters.txt
... | ... | @@ -1772,6 +1772,12 @@ |
1772 | 1772 | purges which is reported from either PAL_VM_SUMMARY or |
1773 | 1773 | SAL PALO. |
1774 | 1774 | |
1775 | + nr_cpus= [SMP] Maximum number of processors that an SMP kernel | |
1776 | + could support. nr_cpus=n : n >= 1 limits the kernel to | |
1777 | + supporting 'n' processors. Later in runtime you can not | |
1778 | + use hotplug cpu feature to put more cpu back to online. | |
1779 | + just like you compile the kernel NR_CPUS=n | |
1780 | + | |
1775 | 1781 | nr_uarts= [SERIAL] maximum number of UARTs to be registered. |
1776 | 1782 | |
1777 | 1783 | numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA. |
arch/ia64/kernel/acpi.c
... | ... | @@ -881,8 +881,8 @@ |
881 | 881 | |
882 | 882 | possible = available_cpus + additional_cpus; |
883 | 883 | |
884 | - if (possible > NR_CPUS) | |
885 | - possible = NR_CPUS; | |
884 | + if (possible > nr_cpu_ids) | |
885 | + possible = nr_cpu_ids; | |
886 | 886 | |
887 | 887 | printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", |
888 | 888 | possible, max((possible - available_cpus), 0)); |
arch/x86/kernel/smpboot.c
... | ... | @@ -1213,11 +1213,12 @@ |
1213 | 1213 | |
1214 | 1214 | total_cpus = max_t(int, possible, num_processors + disabled_cpus); |
1215 | 1215 | |
1216 | - if (possible > CONFIG_NR_CPUS) { | |
1216 | + /* nr_cpu_ids could be reduced via nr_cpus= */ | |
1217 | + if (possible > nr_cpu_ids) { | |
1217 | 1218 | printk(KERN_WARNING |
1218 | 1219 | "%d Processors exceeds NR_CPUS limit of %d\n", |
1219 | - possible, CONFIG_NR_CPUS); | |
1220 | - possible = CONFIG_NR_CPUS; | |
1220 | + possible, nr_cpu_ids); | |
1221 | + possible = nr_cpu_ids; | |
1221 | 1222 | } |
1222 | 1223 | |
1223 | 1224 | printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", |
drivers/acpi/numa.c
... | ... | @@ -279,9 +279,9 @@ |
279 | 279 | /* SRAT: Static Resource Affinity Table */ |
280 | 280 | if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { |
281 | 281 | acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY, |
282 | - acpi_parse_x2apic_affinity, NR_CPUS); | |
282 | + acpi_parse_x2apic_affinity, nr_cpu_ids); | |
283 | 283 | acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, |
284 | - acpi_parse_processor_affinity, NR_CPUS); | |
284 | + acpi_parse_processor_affinity, nr_cpu_ids); | |
285 | 285 | ret = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, |
286 | 286 | acpi_parse_memory_affinity, |
287 | 287 | NR_NODE_MEMBLKS); |
init/main.c
... | ... | @@ -149,6 +149,20 @@ |
149 | 149 | |
150 | 150 | early_param("nosmp", nosmp); |
151 | 151 | |
152 | +/* this is hard limit */ | |
153 | +static int __init nrcpus(char *str) | |
154 | +{ | |
155 | + int nr_cpus; | |
156 | + | |
157 | + get_option(&str, &nr_cpus); | |
158 | + if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) | |
159 | + nr_cpu_ids = nr_cpus; | |
160 | + | |
161 | + return 0; | |
162 | +} | |
163 | + | |
164 | +early_param("nr_cpus", nrcpus); | |
165 | + | |
152 | 166 | static int __init maxcpus(char *str) |
153 | 167 | { |
154 | 168 | get_option(&str, &setup_max_cpus); |