[PATCH 05/19] arm64: smp: Tidy up smp_prepare_cpus()
Jinjie Ruan
ruanjinjie at huawei.com
Tue Sep 8 00:35:26 PDT 2026
在 2026/9/8 0:40, Will Deacon 写道:
> smp_prepare_cpus() is always run on the boot CPU (i.e. CPU 0) but goes
> to great lengths to support running on a CPU where smp_processor_id()
Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> is non-zero.
>
> Clean up the code a little by hardcoding zero for the boot CPU ID.
>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> arch/arm64/kernel/smp.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index a61dc3016a11..ff045080ca1b 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -779,16 +779,14 @@ void __init smp_init_cpus(void)
> void __init smp_prepare_cpus(unsigned int max_cpus)
> {
> const struct cpu_operations *ops;
> - int err;
> unsigned int cpu;
> - unsigned int this_cpu;
> + int err;
>
> init_cpu_topology();
>
> - this_cpu = smp_processor_id();
> - store_cpu_topology(this_cpu);
> - numa_store_cpu_info(this_cpu);
> - numa_add_cpu(this_cpu);
> + store_cpu_topology(0);
> + numa_store_cpu_info(0);
> + numa_add_cpu(0);
>
> /*
> * If UP is mandated by "nosmp" (which implies "maxcpus=0"), don't set
> @@ -803,8 +801,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> * secondaries from the bootloader.
> */
> for_each_possible_cpu(cpu) {
> -
> - if (cpu == smp_processor_id())
> + if (cpu == 0)
> continue;
>
> ops = get_cpu_ops(cpu);
More information about the linux-arm-kernel
mailing list