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 <[email protected]>
Signed-off-by: Jinyang He <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
---
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
help
Say Y to compile the kernel to support NUMA (Non-Uniform Memory
Access). This option improves performance on systems with more
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 38a817e..93cdbb9 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -31,6 +31,8 @@ CONFIG_PERF_EVENTS=y
CONFIG_MACH_LOONGSON64=y
CONFIG_CPU_HAS_MSA=y
CONFIG_NR_CPUS=16
+CONFIG_NUMA=y
+CONFIG_SMP=y
CONFIG_HZ_256=y
CONFIG_KEXEC=y
CONFIG_MIPS32_O32=y
diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h
index fde1b75..ac1c20e 100644
--- a/arch/mips/include/asm/mach-loongson64/loongson.h
+++ b/arch/mips/include/asm/mach-loongson64/loongson.h
@@ -23,8 +23,8 @@ extern u32 memsize, highmemsize;
extern const struct plat_smp_ops loongson3_smp_ops;
/* loongson-specific command line, env and memory initialization */
-extern void __init prom_init_memory(void);
extern void __init prom_init_env(void);
+extern void __init szmem(unsigned int node);
extern void *loongson_fdt_blob;
/* irq operation functions */
diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index ed75f79..e13f704 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -47,6 +47,51 @@ void virtual_early_config(void)
node_id_offset = 44;
}
+void __init szmem(unsigned int node)
+{
+ u32 i, mem_type;
+ static unsigned long num_physpages;
+ u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
+
+ /* Parse memory information and activate */
+ for (i = 0; i < loongson_memmap->nr_map; i++) {
+ node_id = loongson_memmap->map[i].node_id;
+ if (node_id != node)
+ continue;
+
+ mem_type = loongson_memmap->map[i].mem_type;
+ mem_size = loongson_memmap->map[i].mem_size;
+ mem_start = loongson_memmap->map[i].mem_start;
+
+ switch (mem_type) {
+ case SYSTEM_RAM_LOW:
+ case SYSTEM_RAM_HIGH:
+ start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
+ node_psize = (mem_size << 20) >> PAGE_SHIFT;
+ end_pfn = start_pfn + node_psize;
+ num_physpages += node_psize;
+ pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
+ (u32)node_id, mem_type, mem_start, mem_size);
+ pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
+ start_pfn, end_pfn, num_physpages);
+ memblock_add_node(PFN_PHYS(start_pfn), PFN_PHYS(node_psize), node);
+ break;
+ case SYSTEM_RAM_RESERVED:
+ pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
+ (u32)node_id, mem_type, mem_start, mem_size);
+ memblock_reserve(((node_id << 44) + mem_start), mem_size << 20);
+ break;
+ }
+ }
+}
+
+#ifndef CONFIG_NUMA
+static void __init prom_init_memory(void)
+{
+ szmem(0);
+}
+#endif
+
void __init prom_init(void)
{
fw_init_cmdline();
@@ -57,7 +102,11 @@ void __init prom_init(void)
loongson_sysconf.early_config();
+#ifdef CONFIG_NUMA
prom_init_numa_memory();
+#else
+ prom_init_memory();
+#endif
/* Hardcode to CPU UART 0 */
setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE + 0x1e0), 0, 1024);
diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index c6f0c48..a8f57bf 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -25,6 +25,7 @@
#include <asm/time.h>
#include <asm/wbflush.h>
#include <boot_param.h>
+#include <loongson.h>
static struct pglist_data prealloc__node_data[MAX_NUMNODES];
unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
@@ -81,57 +82,6 @@ static void __init init_topology_matrix(void)
}
}
-static void __init szmem(unsigned int node)
-{
- u32 i, mem_type;
- static unsigned long num_physpages;
- u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
-
- /* Parse memory information and activate */
- for (i = 0; i < loongson_memmap->nr_map; i++) {
- node_id = loongson_memmap->map[i].node_id;
- if (node_id != node)
- continue;
-
- mem_type = loongson_memmap->map[i].mem_type;
- mem_size = loongson_memmap->map[i].mem_size;
- mem_start = loongson_memmap->map[i].mem_start;
-
- switch (mem_type) {
- case SYSTEM_RAM_LOW:
- start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
- node_psize = (mem_size << 20) >> PAGE_SHIFT;
- end_pfn = start_pfn + node_psize;
- num_physpages += node_psize;
- pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
- (u32)node_id, mem_type, mem_start, mem_size);
- pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
- start_pfn, end_pfn, num_physpages);
- memblock_add_node(PFN_PHYS(start_pfn),
- PFN_PHYS(node_psize), node);
- break;
- case SYSTEM_RAM_HIGH:
- start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT;
- node_psize = (mem_size << 20) >> PAGE_SHIFT;
- end_pfn = start_pfn + node_psize;
- num_physpages += node_psize;
- pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
- (u32)node_id, mem_type, mem_start, mem_size);
- pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n",
- start_pfn, end_pfn, num_physpages);
- memblock_add_node(PFN_PHYS(start_pfn),
- PFN_PHYS(node_psize), node);
- break;
- case SYSTEM_RAM_RESERVED:
- pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n",
- (u32)node_id, mem_type, mem_start, mem_size);
- memblock_reserve(((node_id << 44) + mem_start),
- mem_size << 20);
- break;
- }
- }
-}
-
static void __init node_mem_init(unsigned int node)
{
unsigned long node_addrspace_offset;
--
2.1.0
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 <[email protected]>
> Signed-off-by: Jinyang He <[email protected]>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> 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.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
On Wed, Dec 16, 2020 at 10:44:23AM +0800, Tiezhu Yang wrote:
> 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.
ok, but compiling IP27 with your patch gives
WARNING: unmet direct dependencies detected for NUMA
Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
Selected by [y]:
- SGI_IP27 [=y] && <choice>
WARNING: unmet direct dependencies detected for NUMA
Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
Selected by [y]:
- SGI_IP27 [=y] && <choice>
WARNING: unmet direct dependencies detected for NUMA
Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
Selected by [y]:
- SGI_IP27 [=y] && <choice>
If I use "select SMP" instead both ip27 and loongson64 compile.
If you are ok with this change, I'll change it while appling your
patch.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
On 12/30/2020 12:39 AM, Thomas Bogendoerfer wrote:
> On Wed, Dec 16, 2020 at 10:44:23AM +0800, Tiezhu Yang wrote:
>> 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.
> ok, but compiling IP27 with your patch gives
>
> WARNING: unmet direct dependencies detected for NUMA
> Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
> Selected by [y]:
> - SGI_IP27 [=y] && <choice>
>
> WARNING: unmet direct dependencies detected for NUMA
> Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
> Selected by [y]:
> - SGI_IP27 [=y] && <choice>
>
> WARNING: unmet direct dependencies detected for NUMA
> Depends on [n]: SYS_SUPPORTS_NUMA [=y] && SMP [=n]
> Selected by [y]:
> - SGI_IP27 [=y] && <choice>
>
> If I use "select SMP" instead both ip27 and loongson64 compile.
>
> If you are ok with this change, I'll change it while appling your
> patch.
No problem, looks good to me, thank you very much.
Thanks,
Tiezhu
>
> Thomas.
>