aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-02-16 11:11:09 -0500
committerTejun Heo <tj@kernel.org>2011-02-16 11:11:09 -0500
commit2e756be44714d0ec2f9827e4f4797c60876167a1 (patch)
treeed9857801b0c2f0d86790e78f5cb5831abb23a60 /arch
parentf9c60251c3d08777db6758cafd959a55a838abd6 (diff)
x86-64, NUMA: make numa_cleanup_meminfo() prettier
* Factor out numa_remove_memblk_from(). * Hole detection doesn't need separate start/end. Calculate start/end once. * Relocate comment. * Define iterators at the top and remove unnecessary prefix increments. This prepares for further improvements to the function. 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>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/mm/numa_64.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index f2721de30a43..4fd3368adc8f 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -230,6 +230,13 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
230 return 0; 230 return 0;
231} 231}
232 232
233static void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi)
234{
235 mi->nr_blks--;
236 memmove(&mi->blk[idx], &mi->blk[idx + 1],
237 (mi->nr_blks - idx) * sizeof(mi->blk[0]));
238}
239
233static __init void cutoff_node(int i, unsigned long start, unsigned long end) 240static __init void cutoff_node(int i, unsigned long start, unsigned long end)
234{ 241{
235 struct bootnode *nd = &numa_nodes[i]; 242 struct bootnode *nd = &numa_nodes[i];
@@ -294,25 +301,25 @@ setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
294 301
295static int __init numa_cleanup_meminfo(struct numa_meminfo *mi) 302static int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
296{ 303{
297 int i; 304 int i, j, k;
298 305
299 /* 306 for (i = 0; i < mi->nr_blks; i++) {
300 * Join together blocks on the same node, holes between
301 * which don't overlap with memory on other nodes.
302 */
303 for (i = 0; i < mi->nr_blks; ++i) {
304 struct numa_memblk *bi = &mi->blk[i]; 307 struct numa_memblk *bi = &mi->blk[i];
305 int j, k;
306 308
307 for (j = i + 1; j < mi->nr_blks; ++j) { 309 for (j = i + 1; j < mi->nr_blks; j++) {
308 struct numa_memblk *bj = &mi->blk[j]; 310 struct numa_memblk *bj = &mi->blk[j];
309 unsigned long start, end; 311 unsigned long start, end;
310 312
313 /*
314 * Join together blocks on the same node, holes
315 * between which don't overlap with memory on other
316 * nodes.
317 */
311 if (bi->nid != bj->nid) 318 if (bi->nid != bj->nid)
312 continue; 319 continue;
313 start = min(bi->end, bj->end); 320 start = min(bi->start, bj->start);
314 end = max(bi->start, bj->start); 321 end = max(bi->end, bj->end);
315 for (k = 0; k < mi->nr_blks; ++k) { 322 for (k = 0; k < mi->nr_blks; k++) {
316 struct numa_memblk *bk = &mi->blk[k]; 323 struct numa_memblk *bk = &mi->blk[k];
317 324
318 if (bi->nid == bk->nid) 325 if (bi->nid == bk->nid)
@@ -322,17 +329,12 @@ static int __init numa_cleanup_meminfo(struct numa_meminfo *mi)
322 } 329 }
323 if (k < mi->nr_blks) 330 if (k < mi->nr_blks)
324 continue; 331 continue;
325 start = min(bi->start, bj->start);
326 end = max(bi->end, bj->end);
327 printk(KERN_INFO "NUMA: Node %d [%Lx,%Lx) + [%Lx,%Lx) -> [%lx,%lx)\n", 332 printk(KERN_INFO "NUMA: Node %d [%Lx,%Lx) + [%Lx,%Lx) -> [%lx,%lx)\n",
328 bi->nid, bi->start, bi->end, bj->start, bj->end, 333 bi->nid, bi->start, bi->end, bj->start, bj->end,
329 start, end); 334 start, end);
330 bi->start = start; 335 bi->start = start;
331 bi->end = end; 336 bi->end = end;
332 k = --mi->nr_blks - j; 337 numa_remove_memblk_from(j--, mi);
333 memmove(mi->blk + j, mi->blk + j + 1,
334 k * sizeof(mi->blk[0]));
335 --j;
336 } 338 }
337 } 339 }
338 340