LoongArch: Add numa_add_reserved_memblk() support in numa
PATCH 1/1 LoongArch: Add numa_add_reserved_memblk() support in numa
This patch fixes the error below when compiling kernel with loongarch's loongson3_defconfig:
drivers/acpi/numa/srat.c: In function ‘acpi_parse_cfmws’:drivers/acpi/numa/srat.c:467:13: error: implicit declaration of function ‘numa_add_reserved_memblk’ [-Werror=implicit-function-declaration]
467 | if (numa_add_reserved_memblk(node, start, end) < 0) {
The error is caused by the missing the newly added numa_add_reserved_memblk (under include/linux/numa_memblks.h) definition inside loongarch's numa related code.
The commit's code(style) was formatted by ./scripts/checkpatch.pl
--- arch/loongarch/include/asm/numa.h | 13 +++++++------ arch/loongarch/kernel/numa.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 9 deletions(-)
arch/loongarch/include/asm/numa.h +7 -6
@@ -28,17 +28,18 @@ struct numa_memblk {int nid; }; -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2)struct numa_meminfo {int nr_blks;struct numa_memblk blk[NR_NODE_MEMBLKS ]; }; -extern int __init numa_add_memblk (int nodeid,u64 start,u64 end); +int __init numa_add_memblk (int nodeid,u64 start,u64 end); +int __init numa_add_reserved_memblk (int nid,u64 start,u64 end); -extern void __init early_numa_add_cpu (int cpuid,s16 node); -extern void numa_add_cpu (unsigned int cpu); -extern void numa_remove_cpu (unsigned int cpu); +void __init early_numa_add_cpu (int cpuid,s16 node); +void numa_add_cpu (unsigned int cpu); +void numa_remove_cpu (unsigned int cpu);static inline void numa_clear_node (int cpu) {
@@ -49,7 +50,7 @@ static inline void set_cpuid_to_node(int cpuid, s16 node) __cpuid_to_node[cpuid] = node; } -extern int early_cpu_to_node (int cpu); +int early_cpu_to_node (int cpu);#else
arch/loongarch/kernel/numa.c +28 -3
@@ -31,6 +31,7 @@ unsigned char node_distances[MAX_NUMNODES][MAX_NUMNODES];EXPORT_SYMBOL (node_distances);static struct numa_meminfo numa_meminfo; +static struct numa_meminfo numa_reserved_meminfo;cpumask_t cpus_on_node[MAX_NUMNODES ];cpumask_t phys_cpus_on_node[MAX_NUMNODES ];EXPORT_SYMBOL (cpus_on_node);
@@ -136,12 +137,14 @@ void __init early_numa_add_cpu(int cpuid, s16 node)void numa_add_cpu (unsigned int cpu) {int nid =cpu_to_node (cpu); +cpumask_set_cpu (cpu, &cpus_on_node[nid]); }void numa_remove_cpu (unsigned int cpu) {int nid =cpu_to_node (cpu); +cpumask_clear_cpu (cpu, &cpus_on_node[nid]); }
@@ -155,7 +158,7 @@ static int __init numa_add_memblk_to(int nid, u64 start, u64 end,/* whine about and ignore invalid blks */ if (start > end || nid <0 || nid >=MAX_NUMNODES ) {pr_warn ("NUMA: Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n" , - nid, start, end -1 ); + nid, start, end -1 );return 0 ; }
@@ -187,6 +190,28 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)return numa_add_memblk_to (nid, start, end, &numa_meminfo); } +/** +* numa_add_reserved_memblk - Add one numa_memblk to numa_reserved_meminfo +* @nid: NUMA node ID of the new memblk +* @start: Start address of the new memblk +* @end: End address of the new memblk +* +* Add a new memblk to the numa_reserved_meminfo. +* +* Usage Case: numa_cleanup_meminfo() reconciles all numa_memblk instances +* against memblock_type information and moves any that intersect reserved +* ranges to numa_reserved_meminfo. However, when that information is known +* ahead of time, we use numa_add_reserved_memblk() to add the numa_memblk +* to numa_reserved_meminfo directly. +* +* RETURNS: +* 0 on success, -errno on failure. +*/ +int __init numa_add_reserved_memblk (int nid,u64 start,u64 end) +{ +return numa_add_memblk_to (nid, start, end, &numa_reserved_meminfo); +} +static void __init node_mem_init (unsigned int node) {unsigned long start_pfn, end_pfn;
@@ -194,7 +219,7 @@ static void __init node_mem_init(unsigned int node) node_addrspace_offset =nid_to_addrbase (node);pr_info ("Node%d's addrspace_offset is 0x%lx\n" , - node, node_addrspace_offset); + node, node_addrspace_offset);get_pfn_range_for_nid (node, &start_pfn, &end_pfn); pr_info("Node%d: start_pfn=0x%lx, end_pfn=0x%lx\n",
@@ -285,7 +310,7 @@ static void __init init_node_memblock(void)case EFI_MEMORY_MAPPED_IO :case EFI_MEMORY_MAPPED_IO_PORT_SPACE :pr_info ("Resvd: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx Bytes\n" , - mem_type, mem_start, mem_size); + mem_type, mem_start, mem_size);break ; } }
Signature · 1 line
2.39.5
Quoted 9 lines · Yulong Han
This patch fixes the error below when compiling kernel with loongarch's
loongson3_defconfig:
drivers/acpi/numa/srat.c: In function ‘acpi_parse_cfmws’:drivers/acpi/numa/srat.c:467:13: error: implicit declaration of function ‘numa_add_reserved_memblk’ [-Werror=implicit-function-declaration] 467 | if (numa_add_reserved_memblk(node, start, end)< 0) {
Quoted 7 lines
The error is caused by the missing the newly added
numa_add_reserved_memblk(underinclude/linux/numa_memblks.h) definition inside loongarch's numa related code.The commit's code(style) was formatted by
./scripts/checkpatch.plSigned-off-by Yulong Han <[email protected]>
Note that numa_add_reserved_memblk would be declared by linux/numa_memblks.h if CONFIG_NUMA_MEMBLKS, and CONFIG_NUMA_MEMBLKS would be select after
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/commit/?h=loongarch-next&id=a24f2fb70cb62180486ad4d74f809ff35ddd1cf9
which would be merged into Torvalds' tree soon. You change fails to notice this and it's just covering up the issue.
Thus
Signature · 2 lines
Xi Ruoyao <[email protected]> School of Aerospace Science and Technology, Xidian University