parisc: simplify smp_prepare_boot_cpu()
PATCH 1/1 parisc: simplify smp_prepare_boot_cpu()
smp_prepare_boot_cpu() reads the cpuid of the first CPU, printing a message to state which processor booted, and setting it online and present.
This cpuid is retrieved from per_cpu(cpu_data, 0).cpuid, which is initialised in arch/parisc/kernel/processor.c:processor_probe() thusly:
p = &per_cpu(cpu_data, cpuid); ... p->cpuid = cpuid; /* save CPU id */
Consequently, the cpuid retrieved seems to be guaranteed to also be zero, meaning that the message printed in this boils down to:
pr_info("SMP: bootstrap CPU ID is 0\n");Moreover, since kernel/cpu.c::boot_cpu_init() already sets CPU 0 to be present and online, there is no need to do this again in smp_prepare_boot_cpu().
Remove this code, and simplify the printk().
--- arch/parisc/kernel/smp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/parisc/kernel/smp.c +1 -6
@@ -404,13 +404,8 @@ static int smp_boot_one_cpu(int cpuid, struct task_struct *idle)void __init smp_prepare_boot_cpu (void ) { -int bootstrap_processor =per_cpu (cpu_data,0 ).cpuid; -/* Setup BSP mappings */ -printk (KERN_INFO "SMP: bootstrap CPU ID is %d\n" , bootstrap_processor); - -set_cpu_online (bootstrap_processor, true); -set_cpu_present (bootstrap_processor, true); +pr_info ("SMP: bootstrap CPU ID is 0\n" ); }
Signature · 1 line
2.30.2
Quoted 16 lines · On Fri, 20 Oct 2023 15:45:30 +0100 "Russell King (Oracle)"…
smp_prepare_boot_cpu()reads the cpuid of the first CPU, printing a message to state which processor booted, and setting it online and present.This cpuid is retrieved from
per_cpu(cpu_data, 0).cpuid, which is initialised in arch/parisc/kernel/processor.c:processor_probe() thusly:p = &per_cpu(cpu_data, cpuid); ... p->cpuid = cpuid; /* save CPU id */Consequently, the cpuid retrieved seems to be guaranteed to also be zero, meaning that the message printed in this boils down to:
pr_info("SMP: bootstrap CPU ID is 0\n");
Quoted 7 lines
Moreover, since kernel/cpu.c::boot_cpu_init() already sets CPU 0 to be present and online, there is no need to do this again in
smp_prepare_boot_cpu().Remove this code, and simplify the
printk().Signed-off-by Russell King (Oracle) <[email protected]>
LGTM, but trivial comment inline.
Quoted 9 lines
--- arch/parisc/kernel/smp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)arch/parisc/kernel/smp.c +0
-0
arch/parisc/kernel/smp.c static int smp_boot_one_cpu(int cpuid, struct task_struct *idle) · line 407
Quoted 6 lines
arch/parisc/kernel/smp.c +0
-2@@ -404,13 +404,8 @@ static int smp_boot_one_cpu(int cpuid, struct task_struct *idle)void __init smp_prepare_boot_cpu (void ) { -int bootstrap_processor =per_cpu (cpu_data,0 ).cpuid; -/* Setup BSP mappings */
Given it's not doing any such thing, I think you should also drop the comment.
Quoted 8 lines
arch/parisc/kernel/smp.c +1
-4-printk (KERN_INFO "SMP: bootstrap CPU ID is %d\n" , bootstrap_processor); - -set_cpu_online (bootstrap_processor, true); -set_cpu_present (bootstrap_processor, true); +pr_info ("SMP: bootstrap CPU ID is 0\n" ); }
Quoted 16 lines · Russell King (Oracle)
smp_prepare_boot_cpu()reads the cpuid of the first CPU, printing a message to state which processor booted, and setting it online and present.This cpuid is retrieved from
per_cpu(cpu_data, 0).cpuid, which is initialised in arch/parisc/kernel/processor.c:processor_probe() thusly:p = &per_cpu(cpu_data, cpuid); ... p->cpuid = cpuid; /* save CPU id */Consequently, the cpuid retrieved seems to be guaranteed to also be zero, meaning that the message printed in this boils down to:
pr_info("SMP: bootstrap CPU ID is 0\n");
Quoted 7 lines
Moreover, since kernel/cpu.c::boot_cpu_init() already sets CPU 0 to be present and online, there is no need to do this again in
smp_prepare_boot_cpu().Remove this code, and simplify the
printk().Signed-off-by Russell King (Oracle) <[email protected]>
applied.
Removed the "Setup BSP mappings" comment too, as
Jonathan Cameron suggested.
Thank you!
Helge
Quoted 23 lines
--- arch/parisc/kernel/smp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)arch/parisc/kernel/smp.c +1
-6@@ -404,13 +404,8 @@ static int smp_boot_one_cpu(int cpuid, struct task_struct *idle)void __init smp_prepare_boot_cpu (void ) { -int bootstrap_processor =per_cpu (cpu_data,0 ).cpuid; -/* Setup BSP mappings */ -printk (KERN_INFO "SMP: bootstrap CPU ID is %d\n" , bootstrap_processor); - -set_cpu_online (bootstrap_processor, true); -set_cpu_present (bootstrap_processor, true); +pr_info ("SMP: bootstrap CPU ID is 0\n" ); }