Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

LoongArch: Fix NUMA node parsing with numa_memblks

On physical machine, NUMA node id comes from high bit 44:48 of physical
address. However it is not true on virt machine. With general method, it
comes from ACPI SRAT table.

Here the common function numa_memblks_init() is used to parse NUMA node
information with numa_memblks.

Cc: <stable@vger.kernel.org>
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

authored by

Bibo Mao and committed by
Huacai Chen
acf5de1b 1c004609

+18 -42
+18 -42
arch/loongarch/kernel/numa.c
··· 158 158 159 159 #ifdef CONFIG_ACPI_NUMA 160 160 161 - /* 162 - * add_numamem_region 163 - * 164 - * Add a uasable memory region described by BIOS. The 165 - * routine gets each intersection between BIOS's region 166 - * and node's region, and adds them into node's memblock 167 - * pool. 168 - * 169 - */ 170 - static void __init add_numamem_region(u64 start, u64 end, u32 type) 171 - { 172 - u32 node = pa_to_nid(start); 173 - u64 size = end - start; 174 - static unsigned long num_physpages; 161 + static unsigned long num_physpages; 175 162 176 - if (start >= end) { 177 - pr_debug("Invalid region: %016llx-%016llx\n", start, end); 178 - return; 179 - } 180 - 181 - num_physpages += (size >> PAGE_SHIFT); 182 - pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n", 183 - node, type, start, size); 184 - pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n", 185 - start >> PAGE_SHIFT, end >> PAGE_SHIFT, num_physpages); 186 - memblock_set_node(start, size, &memblock.memory, node); 187 - } 188 - 189 - static void __init init_node_memblock(void) 163 + static void __init info_node_memblock(void) 190 164 { 191 165 u32 mem_type; 192 166 u64 mem_end, mem_start, mem_size; ··· 180 206 case EFI_BOOT_SERVICES_DATA: 181 207 case EFI_PERSISTENT_MEMORY: 182 208 case EFI_CONVENTIONAL_MEMORY: 183 - add_numamem_region(mem_start, mem_end, mem_type); 209 + num_physpages += (mem_size >> PAGE_SHIFT); 210 + pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n", 211 + (u32)pa_to_nid(mem_start), mem_type, mem_start, mem_size); 212 + pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n", 213 + mem_start >> PAGE_SHIFT, mem_end >> PAGE_SHIFT, num_physpages); 184 214 break; 185 215 case EFI_PAL_CODE: 186 216 case EFI_UNUSABLE_MEMORY: 187 217 case EFI_ACPI_RECLAIM_MEMORY: 188 - add_numamem_region(mem_start, mem_end, mem_type); 218 + num_physpages += (mem_size >> PAGE_SHIFT); 219 + pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n", 220 + (u32)pa_to_nid(mem_start), mem_type, mem_start, mem_size); 221 + pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n", 222 + mem_start >> PAGE_SHIFT, mem_end >> PAGE_SHIFT, num_physpages); 189 223 fallthrough; 190 224 case EFI_RESERVED_TYPE: 191 225 case EFI_RUNTIME_SERVICES_CODE: ··· 231 249 for (i = 0; i < NR_CPUS; i++) 232 250 set_cpuid_to_node(i, NUMA_NO_NODE); 233 251 234 - numa_reset_distance(); 235 - nodes_clear(numa_nodes_parsed); 236 - nodes_clear(node_possible_map); 237 - nodes_clear(node_online_map); 238 - WARN_ON(memblock_clear_hotplug(0, PHYS_ADDR_MAX)); 239 - 240 252 /* Parse SRAT and SLIT if provided by firmware. */ 241 - ret = acpi_disabled ? fake_numa_init() : acpi_numa_init(); 253 + if (!acpi_disabled) 254 + ret = numa_memblks_init(acpi_numa_init, false); 255 + else 256 + ret = numa_memblks_init(fake_numa_init, false); 257 + 242 258 if (ret < 0) 243 259 return ret; 244 260 245 - node_possible_map = numa_nodes_parsed; 246 - if (WARN_ON(nodes_empty(node_possible_map))) 247 - return -EINVAL; 248 - 249 - init_node_memblock(); 261 + info_node_memblock(); 250 262 if (!memblock_validate_numa_coverage(SZ_1M)) 251 263 return -EINVAL; 252 264