aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-04-04 18:23:50 -0400
committerH. Peter Anvin <hpa@zytor.com>2011-04-06 20:57:01 -0400
commit5510db9c1be111528ce46c57f0bec1c9dce258f4 (patch)
treebaac6b88477983f9f6e18e6d7fa14a0e819e217f /arch/x86/mm
parent5b8443b25c0f323ec190d094e4b441957b02664e (diff)
x86-32, numa: Reorganize calculate_numa_remap_page()
Separate the outer node walking loop and per-node logic from calculate_numa_remap_pages(). The outer loop is collapsed into initmem_init() and the per-node logic is moved into a new function - init_alloc_remap(). The new function name is confusing with the existing init_remap_allocator() and the behavior is the function isn't very clean either at this point, but this is to prepare for further cleanups and it will become prettier. This function doesn't introduce any behavior change. Signed-off-by: Tejun Heo <tj@kernel.org> Link: http://lkml.kernel.org/r/1301955840-7246-5-git-send-email-tj@kernel.org Acked-by: Yinghai Lu <yinghai@kernel.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r--arch/x86/mm/numa_32.c125
1 files changed, 62 insertions, 63 deletions
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 60701a5e0de0..5039e9b21d9e 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -264,70 +264,64 @@ void resume_map_numa_kva(pgd_t *pgd_base)
264} 264}
265#endif 265#endif
266 266
267static __init unsigned long calculate_numa_remap_pages(void) 267static __init unsigned long init_alloc_remap(int nid, unsigned long offset)
268{ 268{
269 int nid; 269 unsigned long size;
270 unsigned long size, reserve_pages = 0; 270 u64 node_kva;
271 271
272 for_each_online_node(nid) { 272 /*
273 u64 node_kva; 273 * The acpi/srat node info can show hot-add memroy zones where
274 274 * memory could be added but not currently present.
275 /* 275 */
276 * The acpi/srat node info can show hot-add memroy zones 276 printk(KERN_DEBUG "node %d pfn: [%lx - %lx]\n",
277 * where memory could be added but not currently present. 277 nid, node_start_pfn[nid], node_end_pfn[nid]);
278 */ 278 if (node_start_pfn[nid] > max_pfn)
279 printk(KERN_DEBUG "node %d pfn: [%lx - %lx]\n", 279 return 0;
280 nid, node_start_pfn[nid], node_end_pfn[nid]); 280 if (!node_end_pfn[nid])
281 if (node_start_pfn[nid] > max_pfn) 281 return 0;
282 continue; 282 if (node_end_pfn[nid] > max_pfn)
283 if (!node_end_pfn[nid]) 283 node_end_pfn[nid] = max_pfn;
284 continue; 284
285 if (node_end_pfn[nid] > max_pfn) 285 /* ensure the remap includes space for the pgdat. */
286 node_end_pfn[nid] = max_pfn; 286 size = node_remap_size[nid];
287 287 size += ALIGN(sizeof(pg_data_t), PAGE_SIZE);
288 /* ensure the remap includes space for the pgdat. */ 288
289 size = node_remap_size[nid]; 289 /* convert size to large (pmd size) pages, rounding up */
290 size += ALIGN(sizeof(pg_data_t), PAGE_SIZE); 290 size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES;
291 291 /* now the roundup is correct, convert to PAGE_SIZE pages */
292 /* convert size to large (pmd size) pages, rounding up */ 292 size = size * PTRS_PER_PTE;
293 size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES; 293
294 /* now the roundup is correct, convert to PAGE_SIZE pages */ 294 node_kva = memblock_find_in_range(node_start_pfn[nid] << PAGE_SHIFT,
295 size = size * PTRS_PER_PTE; 295 (u64)node_end_pfn[nid] << PAGE_SHIFT,
296 296 (u64)size << PAGE_SHIFT,
297 node_kva = memblock_find_in_range(node_start_pfn[nid] << PAGE_SHIFT, 297 LARGE_PAGE_BYTES);
298 ((u64)node_end_pfn[nid])<<PAGE_SHIFT, 298 if (node_kva == MEMBLOCK_ERROR)
299 ((u64)size)<<PAGE_SHIFT, 299 panic("Can not get kva ram\n");
300 LARGE_PAGE_BYTES); 300
301 if (node_kva == MEMBLOCK_ERROR) 301 node_remap_size[nid] = size;
302 panic("Can not get kva ram\n"); 302 node_remap_offset[nid] = offset;
303 303 printk(KERN_DEBUG "Reserving %ld pages of KVA for lmem_map of node %d at %llx\n",
304 node_remap_size[nid] = size; 304 size, nid, node_kva >> PAGE_SHIFT);
305 node_remap_offset[nid] = reserve_pages; 305
306 reserve_pages += size; 306 /*
307 printk(KERN_DEBUG "Reserving %ld pages of KVA for lmem_map of" 307 * prevent kva address below max_low_pfn want it on system
308 " node %d at %llx\n", 308 * with less memory later.
309 size, nid, node_kva >> PAGE_SHIFT); 309 * layout will be: KVA address , KVA RAM
310 310 *
311 /* 311 * we are supposed to only record the one less then
312 * prevent kva address below max_low_pfn want it on system 312 * max_low_pfn but we could have some hole in high memory,
313 * with less memory later. 313 * and it will only check page_is_ram(pfn) &&
314 * layout will be: KVA address , KVA RAM 314 * !page_is_reserved_early(pfn) to decide to use it as free.
315 * 315 * So memblock_x86_reserve_range here, hope we don't run out
316 * we are supposed to only record the one less then max_low_pfn 316 * of that array
317 * but we could have some hole in high memory, and it will only 317 */
318 * check page_is_ram(pfn) && !page_is_reserved_early(pfn) to decide 318 memblock_x86_reserve_range(node_kva,
319 * to use it as free. 319 node_kva + ((u64)size << PAGE_SHIFT),
320 * So memblock_x86_reserve_range here, hope we don't run out of that array 320 "KVA RAM");
321 */ 321
322 memblock_x86_reserve_range(node_kva, 322 node_remap_start_pfn[nid] = node_kva >> PAGE_SHIFT;
323 node_kva + (((u64)size)<<PAGE_SHIFT), 323
324 "KVA RAM"); 324 return size;
325
326 node_remap_start_pfn[nid] = node_kva >> PAGE_SHIFT;
327 }
328 printk(KERN_INFO "Reserving total of %lx pages for numa KVA remap\n",
329 reserve_pages);
330 return reserve_pages;
331} 325}
332 326
333static void init_remap_allocator(int nid) 327static void init_remap_allocator(int nid)
@@ -346,6 +340,7 @@ static void init_remap_allocator(int nid)
346 340
347void __init initmem_init(void) 341void __init initmem_init(void)
348{ 342{
343 unsigned long reserve_pages = 0;
349 int nid; 344 int nid;
350 345
351 /* 346 /*
@@ -359,7 +354,11 @@ void __init initmem_init(void)
359 get_memcfg_numa(); 354 get_memcfg_numa();
360 numa_init_array(); 355 numa_init_array();
361 356
362 kva_pages = roundup(calculate_numa_remap_pages(), PTRS_PER_PTE); 357 for_each_online_node(nid)
358 reserve_pages += init_alloc_remap(nid, reserve_pages);
359 kva_pages = roundup(reserve_pages, PTRS_PER_PTE);
360 printk(KERN_INFO "Reserving total of %lx pages for numa KVA remap\n",
361 reserve_pages);
363 362
364 kva_start_pfn = memblock_find_in_range(min_low_pfn << PAGE_SHIFT, 363 kva_start_pfn = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
365 max_low_pfn << PAGE_SHIFT, 364 max_low_pfn << PAGE_SHIFT,