Re: [PATCH] MIPS: Loongson64: Give chance to build under !CONFIG_NUMA and !CONFIG_SMP

From: Tiezhu Yang
Date: Tue Dec 15 2020 - 21:45:12 EST


On 12/15/2020 09:21 PM, Thomas Bogendoerfer wrote:
On Thu, Dec 03, 2020 at 08:32:52PM +0800, Tiezhu Yang wrote:
In the current code, we can not build under !CONFIG_NUMA and !CONFIG_SMP
on the Loongson64 platform, it seems bad for the users who just want to
use pure single core (not nosmp) to debug, so do the following things to
give them a chance:

(1) Do not select NUMA and SMP for MACH_LOONGSON64 in Kconfig, make NUMA
depends on SMP, and then just set them in the loongson3_defconfig.
(2) Move szmem() from numa.c to init.c and add prom_init_memory() under
!CONFIG_NUMA.
(3) Clean up szmem() due to the statements of case SYSTEM_RAM_LOW and
SYSTEM_RAM_HIGH are the same.
(4) Remove the useless declaration of prom_init_memory() and add the
declaration of szmem() in loongson.h to avoid build error.

Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
Signed-off-by: Jinyang He <hejinyang@xxxxxxxxxxx>
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
arch/mips/Kconfig | 3 +-
arch/mips/configs/loongson3_defconfig | 2 +
arch/mips/include/asm/mach-loongson64/loongson.h | 2 +-
arch/mips/loongson64/init.c | 49 ++++++++++++++++++++++
arch/mips/loongson64/numa.c | 52 +-----------------------
5 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 44a47ad..2034c66 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -490,8 +490,6 @@ config MACH_LOONGSON64
select SYS_SUPPORTS_ZBOOT
select SYS_SUPPORTS_RELOCATABLE
select ZONE_DMA32
- select NUMA
- select SMP
select COMMON_CLK
select USE_OF
select BUILTIN_DTB
@@ -2755,6 +2753,7 @@ config ARCH_SPARSEMEM_ENABLE
config NUMA
bool "NUMA Support"
depends on SYS_SUPPORTS_NUMA
+ depends on SMP
can you solve your problem without this hunk ? I don't want to make NUMA
depeding on SMP. NUMA just selects memory archtitecture.

Hi Thomas,

I have tested the following three configs on the Loongson platform:
(1) !NUMA and !SMP,
(2) !NUMA and SMP,
(3) NUMA and SMP,
everything is all right.

But there exists the following build error under NUMA and !SMP:

CC arch/mips/kernel/asm-offsets.s
In file included from ./include/linux/gfp.h:9:0,
from ./include/linux/xarray.h:14,
from ./include/linux/radix-tree.h:19,
from ./include/linux/fs.h:15,
from ./include/linux/compat.h:17,
from arch/mips/kernel/asm-offsets.c:12:
./include/linux/topology.h: In function ‘numa_node_id’:
./include/linux/topology.h:119:2: error: implicit declaration of function ‘cpu_logical_map’ [-Werror=implicit-function-declaration]
return cpu_to_node(raw_smp_processor_id());
^
cc1: some warnings being treated as errors
scripts/Makefile.build:117: recipe for target 'arch/mips/kernel/asm-offsets.s' failed
make[1]: *** [arch/mips/kernel/asm-offsets.s] Error 1
arch/mips/Makefile:396: recipe for target 'archprepare' failed
make: *** [archprepare] Error 2

I find a patch to fix this kind of build errors [1], but it seems
meaningless.

According to the NUMA and SMP description in arch/mips/Kconfig,
we will use only one CPU of a multiprocessor machine if !SMP,
on single node systems leave NUMA disabled.

So I think there is no need to use NUMA if !SMP, and also we should
make NUMA depend on SMP to avoid build errors.

Thanks,
Tiezhu

[1] MIPS: Loongson: Fix complie errors without CONFIG_SMP
https://lore.kernel.org/patchwork/patch/1295704/


Thomas.