Re: [PATCH] LoongArch: Give chance to build under !CONFIG_SMP

From: maobibo
Date: Tue Mar 26 2024 - 21:09:26 EST




On 2024/3/27 上午5:30, Tiezhu Yang wrote:
Hi Bibo,

On 3/26/24 20:58, maobibo wrote:


On 2024/3/26 下午2:21, Tiezhu Yang wrote:
In the current code, SMP is selected in Kconfig for LoongArch, the users
can not unset it, this is reasonable for a multiprocessor machine. But as
the help info of config SMP said, if you have a system with only one CPU,
say N. On a uniprocessor machine, the kernel will run faster if you say N
here.

The Loongson-2K0500 is a single-core CPU for applications like industrial
control, printing terminals, and BMC (Baseboard Management Controller),
there are many development boards, products and solutions on the market,
so it is better and necessary to give a chance to build under !CONFIG_SMP
for a uniprocessor machine.

...

+++ b/arch/loongarch/include/asm/smp.h
@@ -6,6 +6,7 @@
  #ifndef __ASM_SMP_H
  #define __ASM_SMP_H
+#ifdef CONFIG_SMP
  #include <linux/atomic.h>
  #include <linux/bitops.h>
  #include <linux/linkage.h>
@@ -101,4 +102,8 @@ static inline void __cpu_die(unsigned int cpu)
  }
  #endif
+#else /* !CONFIG_SMP */
+#define cpu_logical_map(cpu)    0
It is unsafe here though physical cpuid of BSP is 0 always.
It is better to use __cpu_logical_map[cpu] or read_csr_cpuid()

+#endif
If kernel run with AMP mode where each cpu has its separate kernel img, physical cpuid of BSP will be not 0.

...

+++ b/arch/loongarch/power/suspend.c
@@ -44,7 +44,9 @@ void loongarch_common_resume(void)
  {
      sync_counter();
      local_flush_tlb_all();
+#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
      csr_write64(per_cpu_offset(0), PERCPU_BASE_KS);
+#endif
It is another issue, CONFIG_HAVE_SETUP_PER_CPU_AREA should not depend on NUMA. PERCPU_BASE_KS should be set even for UP.

Thanks for your review and suggestions.

Let me wait for some days, if no more comments, I will address in v3 since the v2 has been sent.
It is fine to me. Do something is better than do nothing, only that we should be careful and it will take much time.

Regards
Bibo Mao

Thanks,
Tiezhu

_______________________________________________
Loongson-kernel mailing list -- loongson-kernel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to loongson-kernel-leave@xxxxxxxxxxxxxxxxx