public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] riscv: print hartid on bringup
@ 2025-03-03  8:34 Yunhui Cui
  2025-03-25  9:59 ` Alexandre Ghiti
  2025-04-03 16:20 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Yunhui Cui @ 2025-03-03  8:34 UTC (permalink / raw)
  To: apatel, atishp, paul.walmsley, palmer, aou, cuiyunhui,
	samuel.holland, alexghiti, jassisinghbrar, takakura,
	valentina.fernandezalanis, ruanjinjie, charlie, conor.dooley,
	haibo1.xu, andybnac, ke.zhao, tglx, linux-riscv, linux-kernel

Firmware randomly releases cores, so CPU numbers don't linearly map
to hartids. When the system has an exception, we care more about hartids.
Adding "dyndbg="file smpboot.c +p" loglevel=8" to the cmdline can output
the hartid.

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
---
 arch/riscv/kernel/smp.c     | 2 ++
 arch/riscv/kernel/smpboot.c | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
index d58b5e751286..e650dec44817 100644
--- a/arch/riscv/kernel/smp.c
+++ b/arch/riscv/kernel/smp.c
@@ -48,6 +48,8 @@ EXPORT_SYMBOL_GPL(__cpuid_to_hartid_map);
 void __init smp_setup_processor_id(void)
 {
 	cpuid_to_hartid_map(0) = boot_cpu_hartid;
+
+	pr_info("Booting Linux on hartid %lu\n", boot_cpu_hartid);
 }
 
 static DEFINE_PER_CPU_READ_MOSTLY(int, ipi_dummy_dev);
diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index e36d20205bd7..601a321e0f17 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -231,6 +231,10 @@ asmlinkage __visible void smp_callin(void)
 	riscv_ipi_enable();
 
 	numa_add_cpu(curr_cpuid);
+
+	pr_debug("CPU%u: Booted secondary hartid %lu\n", curr_cpuid,
+		cpuid_to_hartid_map(curr_cpuid));
+
 	set_cpu_online(curr_cpuid, true);
 
 	/*
-- 
2.39.2


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

* Re: [PATCH v2] riscv: print hartid on bringup
  2025-03-03  8:34 [PATCH v2] riscv: print hartid on bringup Yunhui Cui
@ 2025-03-25  9:59 ` Alexandre Ghiti
  2025-04-03 16:20 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2025-03-25  9:59 UTC (permalink / raw)
  To: Yunhui Cui, apatel, atishp, paul.walmsley, palmer, aou,
	samuel.holland, alexghiti, jassisinghbrar, takakura,
	valentina.fernandezalanis, ruanjinjie, charlie, conor.dooley,
	haibo1.xu, andybnac, ke.zhao, tglx, linux-riscv, linux-kernel

Hi Yunhui,

On 03/03/2025 09:34, Yunhui Cui wrote:
> Firmware randomly releases cores, so CPU numbers don't linearly map
> to hartids. When the system has an exception, we care more about hartids.
> Adding "dyndbg="file smpboot.c +p" loglevel=8" to the cmdline can output
> the hartid.
>
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> ---
>   arch/riscv/kernel/smp.c     | 2 ++
>   arch/riscv/kernel/smpboot.c | 4 ++++
>   2 files changed, 6 insertions(+)
>
> diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c
> index d58b5e751286..e650dec44817 100644
> --- a/arch/riscv/kernel/smp.c
> +++ b/arch/riscv/kernel/smp.c
> @@ -48,6 +48,8 @@ EXPORT_SYMBOL_GPL(__cpuid_to_hartid_map);
>   void __init smp_setup_processor_id(void)
>   {
>   	cpuid_to_hartid_map(0) = boot_cpu_hartid;
> +
> +	pr_info("Booting Linux on hartid %lu\n", boot_cpu_hartid);
>   }
>   
>   static DEFINE_PER_CPU_READ_MOSTLY(int, ipi_dummy_dev);
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index e36d20205bd7..601a321e0f17 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -231,6 +231,10 @@ asmlinkage __visible void smp_callin(void)
>   	riscv_ipi_enable();
>   
>   	numa_add_cpu(curr_cpuid);
> +
> +	pr_debug("CPU%u: Booted secondary hartid %lu\n", curr_cpuid,
> +		cpuid_to_hartid_map(curr_cpuid));
> +
>   	set_cpu_online(curr_cpuid, true);
>   
>   	/*


Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex


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

* Re: [PATCH v2] riscv: print hartid on bringup
  2025-03-03  8:34 [PATCH v2] riscv: print hartid on bringup Yunhui Cui
  2025-03-25  9:59 ` Alexandre Ghiti
@ 2025-04-03 16:20 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-04-03 16:20 UTC (permalink / raw)
  To: yunhui cui
  Cc: linux-riscv, apatel, atishp, paul.walmsley, palmer, aou,
	samuel.holland, alexghiti, jassisinghbrar, takakura,
	valentina.fernandezalanis, ruanjinjie, charlie, conor.dooley,
	haibo1.xu, andybnac, ke.zhao, tglx, linux-kernel

Hello:

This patch was applied to riscv/linux.git (for-next)
by Alexandre Ghiti <alexghiti@rivosinc.com>:

On Mon,  3 Mar 2025 16:34:24 +0800 you wrote:
> Firmware randomly releases cores, so CPU numbers don't linearly map
> to hartids. When the system has an exception, we care more about hartids.
> Adding "dyndbg="file smpboot.c +p" loglevel=8" to the cmdline can output
> the hartid.
> 
> Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
> 
> [...]

Here is the summary with links:
  - [v2] riscv: print hartid on bringup
    https://git.kernel.org/riscv/c/a3313375e88e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-04-03 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-03  8:34 [PATCH v2] riscv: print hartid on bringup Yunhui Cui
2025-03-25  9:59 ` Alexandre Ghiti
2025-04-03 16:20 ` patchwork-bot+linux-riscv

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