* [PATCH] mm/numa_emulation: use the real node id for leftover nodes
@ 2026-11-14 16:47 shao.mingyin
2026-11-14 17:32 ` Lorenzo Stoakes (ARM)
0 siblings, 1 reply; 2+ messages in thread
From: shao.mingyin @ 2026-11-14 16:47 UTC (permalink / raw)
To: akpm, rppt; +Cc: linux-mm, linux-kernel
From: Shao Mingyin <shao.mingyin@zte.com.cn>
mm/numa_emulation: use the real node id for leftover nodes
After assigning fake nodes, fix_pxm_node_maps() gives the remaining
physical nodes free slots in the emulated node space. The second
distance loop in numa_emulation() derives their physical node IDs by
subtracting max_emu_nid from those slots. The slot assignment does not
guarantee that this yields the original physical IDs.
For example, with fake nodes 0 and 1 mapped to physical nodes 0 and 1,
a remaining physical node 2 assigned slot 2 is read as physical node 1.
The wrong row of the physical distance table is then installed.
Record the physical ID when assigning each remaining node's slot and
use that mapping in the distance loop. Keep the first loop's fake-node
distances, and check the physical IDs before indexing the copied table.
Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Build-tested mm/numa_emulation.o and drivers/acpi/numa/srat.o with W=1
and CONFIG_NUMA_EMU=y on x86_64. A C harness using the actual mapping
function and distance-loop excerpts reports physical node 2 to node 0
as 24 before the fix and the expected 27 after it.
The tables and topology were synthetic; no NUMA guest boot was run.
drivers/acpi/numa/srat.c | 2 ++
mm/numa_emulation.c | 24 ++++++++++++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index f5616830f5a9755868779a76a859134671de0178..798aba14cc6e649420644c84797ad0f2dd0751ec 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -154,6 +154,8 @@ int __init fix_pxm_node_maps(int max_nid)
"Number of nodes exceeds MAX_NUMNODES\n"))
return -1;
node_to_pxm_map_copy[j] = node_to_pxm_map[i];
+ /* remember the real node id for emulation distance setup */
+ emu_nid_to_phys[j] = i;
node_set(j, nodes_to_enable);
count++;
}
diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
index 55f26b22bb0be25fff4a29e2d282e7d4459b3e0c..f2321666ed42dc3b765e5eeacaaad8e96974d5c8 100644
--- a/mm/numa_emulation.c
+++ b/mm/numa_emulation.c
@@ -525,18 +525,22 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
u8 dist;
/* distance between fake nodes is already ok */
- if (emu_nid_to_phys[i] != NUMA_NO_NODE &&
- emu_nid_to_phys[j] != NUMA_NO_NODE)
+ if (i <= max_emu_nid && j <= max_emu_nid)
continue;
- if (emu_nid_to_phys[i] != NUMA_NO_NODE)
- physi = emu_nid_to_phys[i];
- else
- physi = i - max_emu_nid;
- if (emu_nid_to_phys[j] != NUMA_NO_NODE)
- physj = emu_nid_to_phys[j];
+ /*
+ * For real nodes fix_pxm_node_maps() has recorded the
+ * physical node id in emu_nid_to_phys[], so use it
+ * instead of deriving a bogus id from the slot.
+ */
+ physi = emu_nid_to_phys[i];
+ physj = emu_nid_to_phys[j];
+ if (physi >= numa_dist_cnt || physi < 0 ||
+ physj >= numa_dist_cnt || physj < 0)
+ dist = physi == physj ?
+ LOCAL_DISTANCE : REMOTE_DISTANCE;
else
- physj = j - max_emu_nid;
- dist = phys_dist[physi * numa_dist_cnt + physj];
+ dist = phys_dist[physi * numa_dist_cnt + physj];
+
numa_set_distance(i, j, dist);
}
}
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mm/numa_emulation: use the real node id for leftover nodes 2026-11-14 16:47 [PATCH] mm/numa_emulation: use the real node id for leftover nodes shao.mingyin @ 2026-11-14 17:32 ` Lorenzo Stoakes (ARM) 0 siblings, 0 replies; 2+ messages in thread From: Lorenzo Stoakes (ARM) @ 2026-11-14 17:32 UTC (permalink / raw) To: shao.mingyin; +Cc: akpm, rppt, linux-mm, linux-kernel On Sun, Nov 15, 2026 at 12:47:06AM +0800, shao.mingyin@zte.com.cn wrote: > From: Shao Mingyin <shao.mingyin@zte.com.cn> > > mm/numa_emulation: use the real node id for leftover nodes > > After assigning fake nodes, fix_pxm_node_maps() gives the remaining > physical nodes free slots in the emulated node space. The second > distance loop in numa_emulation() derives their physical node IDs by > subtracting max_emu_nid from those slots. The slot assignment does not > guarantee that this yields the original physical IDs. > > For example, with fake nodes 0 and 1 mapped to physical nodes 0 and 1, > a remaining physical node 2 assigned slot 2 is read as physical node 1. > The wrong row of the physical distance table is then installed. > > Record the physical ID when assigning each remaining node's slot and > use that mapping in the distance loop. Keep the first loop's fake-node > distances, and check the physical IDs before indexing the copied table. > > Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug") > Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn> NAK. this is generated by some AI slopper's script, spamming the kernel. The patches I looked at were wrong/broken, so no to anything from this person. They've sent 300 mails in under four weeks spanniing: ata, scsi, target, ufs, nvme/nvmet, ubifs, ublk, zloop, dm, md, mmc, virtio-blk, mfd, gpio, pwm, spi, PCI, ASoC, ACPI, net, vfs mount, block partitions, and now mm. and 17 series across 7 subsystems over the past 23 hours. We need a way to ban emails from people like this... -- Cheers, Lorenzo ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-14 17:32 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-14 16:47 [PATCH] mm/numa_emulation: use the real node id for leftover nodes shao.mingyin 2026-11-14 17:32 ` Lorenzo Stoakes (ARM)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®