Skip to content

Commit

Permalink
x86-64, NUMA: Wrap node ID during emulation
Browse files Browse the repository at this point in the history
Both emulation layout functions - split_nodes[_size]_interleave() -
didn't wrap emulated nid while laying out the fake nodes and tried to
avoid interating over the specified number of nodes, which is fragile.

Now that the emulation code generates numa_meminfo, the node memblks
don't need to be consecutive and emulated node IDs can simply wrap.
This makes the code more robust and is necessary for updates to better
handle the cases where the physical nodes are interleaved.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Shaohui Zheng <shaohui.zheng@intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Tejun Heo committed Feb 16, 2011
1 parent c88aea7 commit 775ee85
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions arch/x86/mm/numa_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
memblock_x86_hole_size(end, physnodes[i].end) < size)
end = physnodes[i].end;

/*
* Avoid allocating more nodes than requested, which can
* happen as a result of rounding down each node's size
* to FAKE_NODE_MIN_SIZE.
*/
if (nodes_weight(physnode_mask) + nid >= nr_nodes)
end = physnodes[i].end;

ret = emu_setup_memblk(ei, nid++, i,
ret = emu_setup_memblk(ei, nid++ % nr_nodes, i,
physnodes[i].start,
min(end, physnodes[i].end));
if (ret < 0)
Expand Down Expand Up @@ -873,7 +865,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
memblock_x86_hole_size(end, physnodes[i].end) < size)
end = physnodes[i].end;

ret = emu_setup_memblk(ei, nid++, i,
ret = emu_setup_memblk(ei, nid++ % MAX_NUMNODES, i,
physnodes[i].start,
min(end, physnodes[i].end));
if (ret < 0)
Expand Down

0 comments on commit 775ee85

Please sign in to comment.