public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parisc: simplify smp_prepare_boot_cpu()
@ 2023-10-20 14:45 Russell King (Oracle)
  2023-10-20 14:50 ` Jonathan Cameron
  2023-10-21  7:20 ` Helge Deller
  0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2023-10-20 14:45 UTC (permalink / raw)
  To: Helge Deller, James E.J. Bottomley
  Cc: linux-kernel, James Morse, Jonathan Cameron, Salil Mehta,
	linux-parisc

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().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 arch/parisc/kernel/smp.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 2019c1f04bd0..989efc8c67a5 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -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");
 }
 
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] parisc: simplify smp_prepare_boot_cpu()
  2023-10-20 14:45 [PATCH] parisc: simplify smp_prepare_boot_cpu() Russell King (Oracle)
@ 2023-10-20 14:50 ` Jonathan Cameron
  2023-10-21  7:20 ` Helge Deller
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2023-10-20 14:50 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Helge Deller, James E.J. Bottomley, linux-kernel, James Morse,
	Salil Mehta, linux-parisc

On Fri, 20 Oct 2023 15:45:30 +0100
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:

> 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().
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

LGTM, but trivial comment inline.

> ---
>  arch/parisc/kernel/smp.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
> index 2019c1f04bd0..989efc8c67a5 100644
> --- a/arch/parisc/kernel/smp.c
> +++ b/arch/parisc/kernel/smp.c
> @@ -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.

> -	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");
>  }
>  
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] parisc: simplify smp_prepare_boot_cpu()
  2023-10-20 14:45 [PATCH] parisc: simplify smp_prepare_boot_cpu() Russell King (Oracle)
  2023-10-20 14:50 ` Jonathan Cameron
@ 2023-10-21  7:20 ` Helge Deller
  1 sibling, 0 replies; 3+ messages in thread
From: Helge Deller @ 2023-10-21  7:20 UTC (permalink / raw)
  To: Russell King (Oracle), James E.J. Bottomley
  Cc: linux-kernel, James Morse, Jonathan Cameron, Salil Mehta,
	linux-parisc

On 10/20/23 16:45, Russell King (Oracle) wrote:
> 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().
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

applied.
Removed the "Setup BSP mappings" comment too, as
Jonathan Cameron suggested.

Thank you!
Helge




> ---
>   arch/parisc/kernel/smp.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
> index 2019c1f04bd0..989efc8c67a5 100644
> --- a/arch/parisc/kernel/smp.c
> +++ b/arch/parisc/kernel/smp.c
> @@ -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");
>   }
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-21  7:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 14:45 [PATCH] parisc: simplify smp_prepare_boot_cpu() Russell King (Oracle)
2023-10-20 14:50 ` Jonathan Cameron
2023-10-21  7:20 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox