Skip to content

Commit 6f70bd5

Browse files
Salil Mehtajongwu
Salil Mehta
authored andcommitted
arm64: kernel: Bound the total(present+disabled) cpus with nr_cpu_ids
Bound the total number of identified cpus(including disabled cpus) by maximum allowed limit by the kernel. Max value is either specified as part of the kernel parameters 'nr_cpus' or specified during compile time using CONFIG_NR_CPUS. Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: Xiongfeng Wang <[email protected]>
1 parent 0867205 commit 6f70bd5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

arch/arm64/kernel/smp.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ static int __init smp_cpu_setup(int cpu)
528528
}
529529

530530
static bool bootcpu_valid __initdata;
531+
static bool cpus_clipped __initdata;
531532
static unsigned int cpu_count = 1;
532533
static unsigned int disabled_cpu_count;
533534

@@ -551,6 +552,11 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
551552
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
552553
u64 hwid = processor->arm_mpidr;
553554

555+
if (total_cpu_count > nr_cpu_ids) {
556+
cpus_clipped = true;
557+
return;
558+
}
559+
554560
if (!(processor->flags & ACPI_MADT_ENABLED)) {
555561
#ifndef CONFIG_ACPI_HOTPLUG_CPU
556562
pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid);
@@ -584,9 +590,6 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
584590
return;
585591
}
586592

587-
if (cpu_count >= NR_CPUS)
588-
return;
589-
590593
/* map the logical cpu id to cpu MPIDR */
591594
set_cpu_logical_map(total_cpu_count, hwid);
592595

@@ -704,8 +707,10 @@ static void __init of_parse_and_init_cpus(void)
704707
continue;
705708
}
706709

707-
if (cpu_count >= NR_CPUS)
710+
if (cpu_count >= cpu_possible()) {
711+
cpus_clipped = true;
708712
goto next;
713+
}
709714

710715
pr_debug("cpu logical map 0x%llx\n", hwid);
711716
set_cpu_logical_map(cpu_count, hwid);
@@ -726,16 +731,17 @@ static void __init of_parse_and_init_cpus(void)
726731
*/
727732
void __init smp_init_cpus(void)
728733
{
734+
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
729735
int i;
730736

731737
if (acpi_disabled)
732738
of_parse_and_init_cpus();
733739
else
734740
acpi_parse_and_init_cpus();
735741

736-
if (cpu_count > nr_cpu_ids)
742+
if (cpus_clipped)
737743
pr_warn("Number of cores (%d) exceeds configured maximum of %u - clipping\n",
738-
cpu_count, nr_cpu_ids);
744+
total_cpu_count, nr_cpu_ids);
739745

740746
if (!bootcpu_valid) {
741747
pr_err("missing boot CPU MPIDR, not enabling secondaries\n");

0 commit comments

Comments
 (0)