mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
Merge patch series "treewide, numa_memblks: remove redundant work during NUMA init"
Sang-Heon Jeon <ekffu200098@gmail.com> says: Every existing numa_add_memblk() caller passes a valid node id and separately marks that node in numa_nodes_parsed with node_set(). In addition, numa_nodemask_from_meminfo() recomputes the same "nodes that own memory" set from numa_meminfo, which numa_nodes_parsed already contains. This redundancy implicitly depends on the callers' node_set(). So, before removing the redundancy, make numa_add_memblk() set the node in numa_nodes_parsed explicitly. Then remove the per-caller node_set() and numa_nodemask_from_meminfo(). Also, since the generic numa_register_meminfo() already sets node_possible_map to numa_nodes_parsed, remove the duplicate assignment in arch_numa's numa_register_nodes(). patches from https://patch.msgid.link/20260703041329.2797584-1-ekffu200098@gmail.com: mm: numa_memblks: set numa_nodes_parsed in numa_add_memblk() ACPI: NUMA: remove redundant numa_nodes_parsed node_set() of/numa: remove redundant numa_nodes_parsed node_set() x86/numa: remove redundant numa_nodes_parsed node_set() arch_numa: remove redundant numa_nodes_parsed node_set() LoongArch: remove redundant numa_nodes_parsed node_set() mm: numa_memblks: remove redundant numa_nodemask_from_meminfo() arch_numa: remove redundant node_possible_map assignment mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo() Link: https://patch.msgid.link/20260703041329.2797584-1-ekffu200098@gmail.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
commit
c12c889655
|
|
@ -216,7 +216,6 @@ static int __init fake_numa_init(void)
|
|||
phys_addr_t start = memblock_start_of_DRAM();
|
||||
phys_addr_t end = memblock_end_of_DRAM() - 1;
|
||||
|
||||
node_set(0, numa_nodes_parsed);
|
||||
pr_info("Faking a node at [mem %pap-%pap]\n", &start, &end);
|
||||
|
||||
return numa_add_memblk(0, start, end + 1);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ int __init amd_numa_init(void)
|
|||
|
||||
prevbase = base;
|
||||
numa_add_memblk(nodeid, base, limit);
|
||||
node_set(nodeid, numa_nodes_parsed);
|
||||
}
|
||||
|
||||
if (nodes_empty(numa_nodes_parsed))
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ static int __init dummy_numa_init(void)
|
|||
printk(KERN_INFO "Faking a node at [mem %#018Lx-%#018Lx]\n",
|
||||
0LLU, PFN_PHYS(max_pfn) - 1);
|
||||
|
||||
node_set(0, numa_nodes_parsed);
|
||||
node_set(0, numa_phys_nodes_parsed);
|
||||
numa_add_memblk(0, 0, PFN_PHYS(max_pfn));
|
||||
|
||||
|
|
|
|||
|
|
@ -399,8 +399,6 @@ acpi_parse_memory_affinity(union acpi_subtable_headers *header,
|
|||
goto out_err_bad_srat;
|
||||
}
|
||||
|
||||
node_set(node, numa_nodes_parsed);
|
||||
|
||||
pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s%s\n",
|
||||
node, pxm,
|
||||
(unsigned long long) start, (unsigned long long) end - 1,
|
||||
|
|
|
|||
|
|
@ -221,9 +221,6 @@ static int __init numa_register_nodes(void)
|
|||
node_set_online(nid);
|
||||
}
|
||||
|
||||
/* Setup online nodes to actual nodes*/
|
||||
node_possible_map = numa_nodes_parsed;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -283,7 +280,6 @@ static int __init dummy_numa_init(void)
|
|||
pr_err("NUMA init failed\n");
|
||||
return ret;
|
||||
}
|
||||
node_set(0, numa_nodes_parsed);
|
||||
|
||||
numa_off = true;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -59,11 +59,8 @@ static int __init of_numa_parse_memory_nodes(void)
|
|||
r = -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; !r && !of_address_to_resource(np, i, &rsrc); i++) {
|
||||
for (i = 0; !r && !of_address_to_resource(np, i, &rsrc); i++)
|
||||
r = numa_add_memblk(nid, rsrc.start, rsrc.end + 1);
|
||||
if (!r)
|
||||
node_set(nid, numa_nodes_parsed);
|
||||
}
|
||||
|
||||
if (!i || r) {
|
||||
of_node_put(np);
|
||||
|
|
|
|||
|
|
@ -17,20 +17,6 @@ nodemask_t numa_nodes_parsed __initdata;
|
|||
static struct numa_meminfo numa_meminfo __initdata_or_meminfo;
|
||||
static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo;
|
||||
|
||||
/*
|
||||
* Set nodes, which have memory in @mi, in *@nodemask.
|
||||
*/
|
||||
static void __init numa_nodemask_from_meminfo(nodemask_t *nodemask,
|
||||
const struct numa_meminfo *mi)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mi->blk); i++)
|
||||
if (mi->blk[i].start != mi->blk[i].end &&
|
||||
mi->blk[i].nid != NUMA_NO_NODE)
|
||||
node_set(mi->blk[i].nid, *nodemask);
|
||||
}
|
||||
|
||||
/**
|
||||
* numa_reset_distance - Reset NUMA distance table
|
||||
*
|
||||
|
|
@ -56,7 +42,6 @@ static int __init numa_alloc_distance(void)
|
|||
|
||||
/* size the new table and allocate it */
|
||||
nodes_parsed = numa_nodes_parsed;
|
||||
numa_nodemask_from_meminfo(&nodes_parsed, &numa_meminfo);
|
||||
|
||||
for_each_node_mask(i, nodes_parsed)
|
||||
cnt = i;
|
||||
|
|
@ -135,13 +120,20 @@ EXPORT_SYMBOL(__node_distance);
|
|||
static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
|
||||
struct numa_meminfo *mi)
|
||||
{
|
||||
/* whine about and ignore invalid nid */
|
||||
if (nid < 0 || nid >= MAX_NUMNODES) {
|
||||
pr_warn("Warning: invalid memblk node id %d [mem %#010Lx-%#010Lx]\n",
|
||||
nid, start, end - 1);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* ignore zero length blks */
|
||||
if (start == end)
|
||||
return 0;
|
||||
|
||||
/* whine about and ignore invalid blks */
|
||||
if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
|
||||
pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
|
||||
/* whine about and ignore invalid ranges */
|
||||
if (start > end) {
|
||||
pr_warn("Warning: invalid memblk range for node %d [mem %#010Lx-%#010Lx]\n",
|
||||
nid, start, end - 1);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -193,13 +185,20 @@ static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx,
|
|||
* @end: End address of the new memblk
|
||||
*
|
||||
* Add a new memblk to the default numa_meminfo.
|
||||
* On success @nid is also set in numa_nodes_parsed.
|
||||
*
|
||||
* RETURNS:
|
||||
* 0 on success, -errno on failure.
|
||||
*/
|
||||
int __init numa_add_memblk(int nid, u64 start, u64 end)
|
||||
{
|
||||
return numa_add_memblk_to(nid, start, end, &numa_meminfo);
|
||||
int ret;
|
||||
|
||||
ret = numa_add_memblk_to(nid, start, end, &numa_meminfo);
|
||||
if (!ret)
|
||||
node_set(nid, numa_nodes_parsed);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -256,8 +255,7 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
|
|||
|
||||
/* preserve info for non-RAM areas above 'max_pfn': */
|
||||
if (bi->end > high) {
|
||||
numa_add_memblk_to(bi->nid, high, bi->end,
|
||||
&numa_reserved_meminfo);
|
||||
numa_add_reserved_memblk(bi->nid, high, bi->end);
|
||||
bi->end = high;
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +399,6 @@ static int __init numa_register_meminfo(struct numa_meminfo *mi)
|
|||
|
||||
/* Account for nodes with cpus and no memory */
|
||||
node_possible_map = numa_nodes_parsed;
|
||||
numa_nodemask_from_meminfo(&node_possible_map, mi);
|
||||
if (WARN_ON(nodes_empty(node_possible_map)))
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user