Skip to content

Commit df5545a

Browse files
hqszgregkh
authored andcommitted
mm/fake-numa: fix under-allocation detection in uniform split
[ Upstream commit 3a3fc1d ] When splitting NUMA node uniformly, split_nodes_size_interleave_uniform() returns the next absolute node ID, not the number of nodes created. The existing under-allocation detection logic compares next absolute node ID (ret) and request count (n), which only works when nid starts at 0. For example, on a system with 2 physical NUMA nodes (node 0: 2GB, node 1: 128MB) and numa=fake=8U, 8 fake nodes are successfully created from node 0 and split_nodes_size_interleave_uniform() returns 8. For node 1, fake node nid starts at 8, but only 4 fake nodes are created due to current FAKE_NODE_MIN_SIZE being 32MB, and split_nodes_size_interleave_uniform() returns 12. By existing under-allocation detection logic, "ret < n" (12 < 8) is false, so the under-allocation will not be detected. Fix under-allocation detection logic to compare the number of actually created nodes (ret - nid) against the request count (n). Also skip under-allocation detection logic for memoryless physical nodes where no fake nodes are created. Also, fix the outdated comment describing split_nodes_size_interleave_uniform() to match the actual return value. Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com> Reported-by: Donghyeon Lee <asd142513@gmail.com> Reported-by: Munhui Chae <mochae@student.42seoul.kr> Fixes: cc9aec0 ("x86/numa_emulation: Introduce uniform split capability") # 4.19 Link: https://patch.msgid.link/20260417135805.1758378-1-ekffu200098@gmail.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5fecb71 commit df5545a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

arch/x86/mm/numa_emulation.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static u64 uniform_size(u64 max_addr, u64 base, u64 hole, int nr_nodes)
211211
* Sets up fake nodes of `size' interleaved over physical nodes ranging from
212212
* `addr' to `max_addr'.
213213
*
214-
* Returns zero on success or negative on error.
214+
* Returns node ID of the next node on success or negative error code.
215215
*/
216216
static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei,
217217
struct numa_meminfo *pi,
@@ -395,7 +395,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
395395
if (strchr(emu_cmdline, 'U')) {
396396
nodemask_t physnode_mask = numa_nodes_parsed;
397397
unsigned long n;
398-
int nid = 0;
398+
int nid = 0, nr_created;
399399

400400
n = simple_strtoul(emu_cmdline, &emu_cmdline, 0);
401401
ret = -1;
@@ -413,9 +413,18 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
413413
n, &pi.blk[0], nid);
414414
if (ret < 0)
415415
break;
416-
if (ret < n) {
416+
417+
/*
418+
* If no memory was found for this physical node,
419+
* skip the under-allocation check.
420+
*/
421+
if (ret == nid)
422+
continue;
423+
424+
nr_created = ret - nid;
425+
if (nr_created < n) {
417426
pr_info("%s: phys: %d only got %d of %ld nodes, failing\n",
418-
__func__, i, ret, n);
427+
__func__, i, nr_created, n);
419428
ret = -1;
420429
break;
421430
}

0 commit comments

Comments
 (0)