* [PATCH 1/9] mm: numa_memblks: set numa_nodes_parsed in numa_add_memblk()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
[not found] ` <178298867638.1436291.11279946475033863942.b4-review@b4>
2026-06-28 13:58 ` [PATCH 2/9] ACPI: NUMA: remove redundant numa_nodes_parsed node_set() Sang-Heon Jeon
` (8 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Andrew Morton, Mike Rapoport; +Cc: Sang-Heon Jeon, linux-mm
Every existing numa_add_memblk() caller separately marks the new node in
numa_nodes_parsed with node_set(). Set the node in numa_add_memblk() itself
on a successful add, so this no longer depends on each caller.
numa_add_memblk_to() now returns -EINVAL for an out-of-range node id, so a
zero return implies @nid was valid. No existing caller passes an
invalid one, so existing callers are unaffected.
The per-caller node_set() calls are removed in later patches.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
mm/numa_memblks.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index 3c3c4eac3514..2d92ca38c02a 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -135,14 +135,17 @@ EXPORT_SYMBOL(__node_distance);
static int __init numa_add_memblk_to(int nid, u64 start, u64 end,
struct numa_meminfo *mi)
{
- /* ignore zero length blks */
- if (start == end)
- return 0;
-
/* whine about and ignore invalid blks */
- if (start > end || nid < 0 || nid >= MAX_NUMNODES) {
+ if (nid < 0 || nid >= MAX_NUMNODES) {
pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
nid, start, end - 1);
+ return -EINVAL;
+ }
+
+ /* ignore zero length or invalid blks */
+ if (start >= end) {
+ pr_warn("Warning: invalid memblk node size %d [mem %#010Lx-%#010Lx]\n",
+ nid, start, end - 1);
return 0;
}
@@ -193,13 +196,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;
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/9] ACPI: NUMA: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 1/9] mm: numa_memblks: set numa_nodes_parsed in numa_add_memblk() Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 3/9] of/numa: " Sang-Heon Jeon
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Sang-Heon Jeon, Len Brown, linux-acpi
numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
caller's own node_set() is redundant. Remove it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
drivers/acpi/numa/srat.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 62d4a8df0b8c..5c407dc6401e 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -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,
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/9] of/numa: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 1/9] mm: numa_memblks: set numa_nodes_parsed in numa_add_memblk() Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 2/9] ACPI: NUMA: remove redundant numa_nodes_parsed node_set() Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-30 16:51 ` Rob Herring (Arm)
2026-06-28 13:58 ` [PATCH 5/9] arch_numa: " Sang-Heon Jeon
` (6 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan; +Cc: Sang-Heon Jeon, devicetree
numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
caller's own node_set() is redundant. Remove it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
drivers/of/of_numa.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index cd2dc8e825c9..230d5f628c1b 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 3/9] of/numa: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 ` [PATCH 3/9] of/numa: " Sang-Heon Jeon
@ 2026-06-30 16:51 ` Rob Herring (Arm)
0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring (Arm) @ 2026-06-30 16:51 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: devicetree, Saravana Kannan
On Sun, 28 Jun 2026 22:58:17 +0900, Sang-Heon Jeon wrote:
> numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
> caller's own node_set() is redundant. Remove it.
>
> No functional change.
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> drivers/of/of_numa.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/9] arch_numa: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (2 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 3/9] of/numa: " Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 6/9] LoongArch: " Sang-Heon Jeon
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
Cc: Sang-Heon Jeon, driver-core
numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
caller's own node_set() is redundant. Remove it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
drivers/base/arch_numa.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
index c99f2ab105e5..19bc806313c4 100644
--- a/drivers/base/arch_numa.c
+++ b/drivers/base/arch_numa.c
@@ -283,7 +283,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;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 6/9] LoongArch: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (3 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 5/9] arch_numa: " Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 7/9] mm: numa_memblks: remove redundant numa_nodemask_from_meminfo() Sang-Heon Jeon
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Huacai Chen; +Cc: Sang-Heon Jeon, loongarch, WANG Xuerui
numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
caller's own node_set() is redundant. Remove it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
arch/loongarch/kernel/numa.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c
index 8b89898e20df..c96c53623715 100644
--- a/arch/loongarch/kernel/numa.c
+++ b/arch/loongarch/kernel/numa.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 7/9] mm: numa_memblks: remove redundant numa_nodemask_from_meminfo()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (4 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 6/9] LoongArch: " Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 8/9] arch_numa: remove redundant node_possible_map assignment Sang-Heon Jeon
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Andrew Morton, Mike Rapoport; +Cc: Sang-Heon Jeon, linux-mm
numa_add_memblk() now sets each added node in numa_nodes_parsed, so
numa_nodes_parsed already contains every node that owns memory. The nodes
numa_nodemask_from_meminfo() adds from numa_meminfo are already set, so the
calls in numa_alloc_distance() and numa_register_meminfo() are redundant.
So remove both call sites and the unused function itself.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
mm/numa_memblks.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index 2d92ca38c02a..edc231538954 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -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;
@@ -411,7 +396,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;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 8/9] arch_numa: remove redundant node_possible_map assignment
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (5 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 7/9] mm: numa_memblks: remove redundant numa_nodemask_from_meminfo() Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 13:58 ` [PATCH 9/9] mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo() Sang-Heon Jeon
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
Cc: Sang-Heon Jeon, driver-core
numa_register_meminfo() sets node_possible_map to numa_nodes_parsed. The
later assignment in numa_register_nodes() is therefore redundant, so remove
it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
drivers/base/arch_numa.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
index 19bc806313c4..d4e426aa51c5 100644
--- a/drivers/base/arch_numa.c
+++ b/drivers/base/arch_numa.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 9/9] mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (6 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 8/9] arch_numa: remove redundant node_possible_map assignment Sang-Heon Jeon
@ 2026-06-28 13:58 ` Sang-Heon Jeon
2026-06-28 14:18 ` [PATCH 4/9] x86/numa: remove redundant numa_nodes_parsed node_set() Sang-Heon Jeon
2026-07-02 10:39 ` [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Mike Rapoport
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 13:58 UTC (permalink / raw)
To: Andrew Morton, Mike Rapoport; +Cc: Sang-Heon Jeon, linux-mm
numa_cleanup_meminfo() calls the internal numa_add_memblk_to() to add a
block to numa_reserved_meminfo, even though numa_add_reserved_memblk()
wraps exactly that.
Use the wrapper instead, so numa_add_memblk_to() is only called through
its two wrappers.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
mm/numa_memblks.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c
index edc231538954..86b84a89fd9e 100644
--- a/mm/numa_memblks.c
+++ b/mm/numa_memblks.c
@@ -251,8 +251,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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/9] x86/numa: remove redundant numa_nodes_parsed node_set()
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (7 preceding siblings ...)
2026-06-28 13:58 ` [PATCH 9/9] mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo() Sang-Heon Jeon
@ 2026-06-28 14:18 ` Sang-Heon Jeon
2026-07-02 10:39 ` [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Mike Rapoport
9 siblings, 0 replies; 13+ messages in thread
From: Sang-Heon Jeon @ 2026-06-28 14:18 UTC (permalink / raw)
To: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
Ingo Molnar, Borislav Petkov
Cc: Sang-Heon Jeon, H. Peter Anvin, linux-kernel, x86
numa_add_memblk() now sets the node in numa_nodes_parsed itself, so the
caller's own node_set() is redundant. Remove it.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
arch/x86/mm/amdtopology.c | 1 -
arch/x86/mm/numa.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c
index f980b0eb0105..1cb581bbf2b6 100644
--- a/arch/x86/mm/amdtopology.c
+++ b/arch/x86/mm/amdtopology.c
@@ -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))
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 99d0a9332c14..ced66e68a68e 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -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));
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init
2026-06-28 13:58 [PATCH 0/9] treewide, numa_memblks: remove redundant work during NUMA init Sang-Heon Jeon
` (8 preceding siblings ...)
2026-06-28 14:18 ` [PATCH 4/9] x86/numa: remove redundant numa_nodes_parsed node_set() Sang-Heon Jeon
@ 2026-07-02 10:39 ` Mike Rapoport
9 siblings, 0 replies; 13+ messages in thread
From: Mike Rapoport @ 2026-07-02 10:39 UTC (permalink / raw)
To: Sang-Heon Jeon
Cc: Andrew Morton, Andy Lutomirski, Borislav Petkov, Danilo Krummrich,
Dave Hansen, Greg Kroah-Hartman, Huacai Chen, Ingo Molnar,
Mike Rapoport, Peter Zijlstra, Rafael J. Wysocki, Rob Herring,
Saravana Kannan, Thomas Gleixner, devicetree, driver-core,
H. Peter Anvin, Len Brown, linux-acpi, linux-mm, loongarch,
WANG Xuerui, x86, linux-kernel
Hi,
> 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().
>
> Patch 1 adds the node_set() to numa_add_memblk() itself, so every memblk's
> node is set in numa_nodes_parsed on add.
>
> Patches 2-6 depend on patch 1 and remove the redundant per-caller node_set()
> from all callers.
>
> Patch 7 removes both numa_nodemask_from_meminfo() call sites and the unused
> function itself.
>
> Patch 8 removes the duplicate node_possible_map assignment in arch_numa.
>
> Patch 9 is a minor cleanup, using the existing numa_add_reserved_memblk()
> wrapper in numa_cleanup_meminfo().
>
> No functional change.
Looks good to me.
Can you please address the small comment for patch 1?
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 13+ messages in thread