[PATCH 2/4] LoongArch: smp: Add all CPUs enabled by fdt to NUMA node 0

Jiaxun Yang posted 4 patches 1 year, 8 months ago
There is a newer version of this series
[PATCH 2/4] LoongArch: smp: Add all CPUs enabled by fdt to NUMA node 0
Posted by Jiaxun Yang 1 year, 8 months ago
NUMA enabled kernel on FDT based machine fails to boot
because CPUs are all in NUMA_NO_NODE and mm subsystem
won't accept that.

Fix by adding them to default NUMA node for now.

Cc: stable@vger.kernel.org
Fixes: 88d4d957edc7 ("LoongArch: Add FDT booting support from efi system table")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 arch/loongarch/kernel/smp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
index 0dfe2388ef41..866757b76ecb 100644
--- a/arch/loongarch/kernel/smp.c
+++ b/arch/loongarch/kernel/smp.c
@@ -273,7 +273,6 @@ static void __init fdt_smp_setup(void)
 
 		if (cpuid == loongson_sysconf.boot_cpu_id) {
 			cpu = 0;
-			numa_add_cpu(cpu);
 		} else {
 			cpu = cpumask_next_zero(-1, cpu_present_mask);
 		}
@@ -283,6 +282,10 @@ static void __init fdt_smp_setup(void)
 		set_cpu_present(cpu, true);
 		__cpu_number_map[cpuid] = cpu;
 		__cpu_logical_map[cpu] = cpuid;
+
+		early_numa_add_cpu(cpu, 0);
+		set_cpuid_to_node(cpuid, 0);
+		numa_add_cpu(cpu);
 	}
 
 	loongson_sysconf.nr_cpus = num_processors;

-- 
2.43.0
Re: [PATCH 2/4] LoongArch: smp: Add all CPUs enabled by fdt to NUMA node 0
Posted by kernel test robot 1 year, 8 months ago
Hi Jiaxun,

kernel test robot noticed the following build errors:

[auto build test ERROR on 124cfbcd6d185d4f50be02d5f5afe61578916773]

url:    https://github.com/intel-lab-lkp/linux/commits/Jiaxun-Yang/LoongArch-Fix-built-in-DTB-detection/20240522-041534
base:   124cfbcd6d185d4f50be02d5f5afe61578916773
patch link:    https://lore.kernel.org/r/20240521-loongarch-booting-fixes-v1-2-659c201c0370%40flygoat.com
patch subject: [PATCH 2/4] LoongArch: smp: Add all CPUs enabled by fdt to NUMA node 0
config: loongarch-randconfig-001-20240524 (https://download.01.org/0day-ci/archive/20240524/202405240627.5Ey7vV8v-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405240627.5Ey7vV8v-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405240627.5Ey7vV8v-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/loongarch/kernel/smp.c: In function 'fdt_smp_setup':
>> arch/loongarch/kernel/smp.c:287:17: error: implicit declaration of function 'set_cpuid_to_node'; did you mean 'set_cpu_numa_node'? [-Werror=implicit-function-declaration]
     287 |                 set_cpuid_to_node(cpuid, 0);
         |                 ^~~~~~~~~~~~~~~~~
         |                 set_cpu_numa_node
   cc1: some warnings being treated as errors


vim +287 arch/loongarch/kernel/smp.c

   259	
   260	static void __init fdt_smp_setup(void)
   261	{
   262	#ifdef CONFIG_OF
   263		unsigned int cpu, cpuid;
   264		struct device_node *node = NULL;
   265	
   266		for_each_of_cpu_node(node) {
   267			if (!of_device_is_available(node))
   268				continue;
   269	
   270			cpuid = of_get_cpu_hwid(node, 0);
   271			if (cpuid >= nr_cpu_ids)
   272				continue;
   273	
   274			if (cpuid == loongson_sysconf.boot_cpu_id) {
   275				cpu = 0;
   276			} else {
   277				cpu = cpumask_next_zero(-1, cpu_present_mask);
   278			}
   279	
   280			num_processors++;
   281			set_cpu_possible(cpu, true);
   282			set_cpu_present(cpu, true);
   283			__cpu_number_map[cpuid] = cpu;
   284			__cpu_logical_map[cpu] = cpuid;
   285	
   286			early_numa_add_cpu(cpu, 0);
 > 287			set_cpuid_to_node(cpuid, 0);
   288			numa_add_cpu(cpu);
   289		}
   290	
   291		loongson_sysconf.nr_cpus = num_processors;
   292		set_bit(0, loongson_sysconf.cores_io_master);
   293	#endif
   294	}
   295	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki