Message ID | e2f3ee03-24e7-fd28-4172-ff0c87f9f539@huawei.com |
---|---|
State | New |
Headers | show |
On 2016/8/5 18:19, Suzuki K Poulose wrote: > On 05/08/16 10:58, Kefeng Wang wrote: >> >> >> On 2016/8/5 16:32, Will Deacon wrote: >>> On Fri, Aug 05, 2016 at 02:03:55PM +0800, Kefeng Wang wrote: >>>> Enable the hard limit of cpu count by nr_cpus on arm64. >>>> The code is borrowed from MIPS. >>>> [...] > > Or is this even better ? Agree, and let's show a better warning. > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 490db85..dbd6a5e 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -659,9 +659,9 @@ void __init smp_init_cpus(void) > acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, > acpi_parse_gic_cpu_interface, 0); > > - if (cpu_count > NR_CPUS) > + if (cpu_count > nr_cpu_ids) > pr_warn("no. of cores (%d) greater than configured maximum of %d - clipping\n", change to pr_warn("%d cores exceeds configured maximum of %d - clipping\n", Thanks, Kefeng > - cpu_count, NR_CPUS); > + cpu_count, nr_cpu_ids); > > if (!bootcpu_valid) { > pr_err("missing boot CPU MPIDR, not enabling secondaries\n"); > @@ -675,7 +675,7 @@ void __init smp_init_cpus(void) > * with entries in cpu_logical_map while initializing the cpus. > * If the cpu set-up fails, invalidate the cpu_logical_map entry. > */ > - for (i = 1; i < NR_CPUS; i++) { > + for (i = 1; i < nr_cpu_ids; i++) { > if (cpu_logical_map(i) != INVALID_HWID) { > if (smp_cpu_setup(i)) > cpu_logical_map(i) = INVALID_HWID; > > > Cheers > Suzuki > > . > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 76a6d92..0ac3ff5 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -496,7 +496,10 @@ static int __init smp_cpu_setup(int cpu) if (cpu_ops[cpu]->cpu_init(cpu)) return -ENODEV; - set_cpu_possible(cpu, true); + if (cpu < nr_cpu_ids) + set_cpu_possible(cpu, true); + else + return -EINVAL; return 0; }