xen/numa: fix setup of non-aligned memory affinity ranges

The logic to populate memnodemap in populate_memnodemap() assumes that all
ranges are aligned to the hash shift, this however is only true for the
first address in a memory affinity node.  Any subsequent ranges belonging
to the same node might not be aligned to the hash shift value.

Such lack of alignment causes issues to the logic in populate_memnodemap(),
as then the tail of the range might not be properly accounted for and setup
in memnodemap.  Fix this by forcing the start address of all regions to
be aligned to the hash shift; if such alignment causes a region overlap it
would always be between regions on the same node, and hence will never
cause setup issues of the memnodemap array.

Fixes: 1666086b00 ("x86/NUMA: improve memnode_shift calculation for multi node system")
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 188d530529
master date: 2026-06-05 19:13:47 +0200
This commit is contained in:
Roger Pau Monné authored and Jan Beulich committed 2026-07-20 13:29:16 +02:00
1 parent 137827d858
commit 94fa7e1626
1 file changed
+6
+6
View File
@@ -403,6 +403,12 @@ static int __init populate_memnodemap(const struct node *nodes,
if ( (epdx >> shift) >= memnodemapsize )
return 0;
/*
* Round down start address: if start is not aligned to the memnodemap
* chunk size the tail remainder might not be added. Overlaps created
* by rounding will fall into the same NUMA region.
*/
spdx = ROUNDDOWN(spdx, 1UL << shift);
do {
if ( memnodemap[spdx >> shift] != NUMA_NO_NODE &&
(!nodeids || memnodemap[spdx >> shift] != nodeids[i]) )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.