diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-07-03 18:04:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:37 -0400 |
commit | 369a9d8523dc7317eccb64b7aee6e9641d84cc8b (patch) | |
tree | 9a7872928fd74bc52e8f49d256ce88ae390532f6 /arch/powerpc/mm | |
parent | 7d2c7747086354f7889e8d577c537f9ad8985230 (diff) |
mm/ppc: prepare for removing num_physpages and simplify mem_init()
Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/mem.c | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 3bcfc0d0d322..49c18b60bbb4 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -299,46 +299,27 @@ void __init paging_init(void) | |||
299 | 299 | ||
300 | void __init mem_init(void) | 300 | void __init mem_init(void) |
301 | { | 301 | { |
302 | #ifdef CONFIG_NEED_MULTIPLE_NODES | ||
303 | int nid; | ||
304 | #endif | ||
305 | pg_data_t *pgdat; | ||
306 | unsigned long i; | ||
307 | struct page *page; | ||
308 | unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; | ||
309 | |||
310 | #ifdef CONFIG_SWIOTLB | 302 | #ifdef CONFIG_SWIOTLB |
311 | swiotlb_init(0); | 303 | swiotlb_init(0); |
312 | #endif | 304 | #endif |
313 | 305 | ||
314 | num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT; | ||
315 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); | 306 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); |
316 | 307 | ||
317 | #ifdef CONFIG_NEED_MULTIPLE_NODES | 308 | #ifdef CONFIG_NEED_MULTIPLE_NODES |
318 | for_each_online_node(nid) { | 309 | { |
319 | if (NODE_DATA(nid)->node_spanned_pages != 0) { | 310 | pg_data_t *pgdat; |
320 | printk("freeing bootmem node %d\n", nid); | 311 | |
321 | free_all_bootmem_node(NODE_DATA(nid)); | 312 | for_each_online_pgdat(pgdat) |
322 | } | 313 | if (pgdat->node_spanned_pages != 0) { |
314 | printk("freeing bootmem node %d\n", | ||
315 | pgdat->node_id); | ||
316 | free_all_bootmem_node(pgdat); | ||
317 | } | ||
323 | } | 318 | } |
324 | #else | 319 | #else |
325 | max_mapnr = max_pfn; | 320 | max_mapnr = max_pfn; |
326 | free_all_bootmem(); | 321 | free_all_bootmem(); |
327 | #endif | 322 | #endif |
328 | for_each_online_pgdat(pgdat) { | ||
329 | for (i = 0; i < pgdat->node_spanned_pages; i++) { | ||
330 | if (!pfn_valid(pgdat->node_start_pfn + i)) | ||
331 | continue; | ||
332 | page = pgdat_page_nr(pgdat, i); | ||
333 | if (PageReserved(page)) | ||
334 | reservedpages++; | ||
335 | } | ||
336 | } | ||
337 | |||
338 | codesize = (unsigned long)&_sdata - (unsigned long)&_stext; | ||
339 | datasize = (unsigned long)&_edata - (unsigned long)&_sdata; | ||
340 | initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin; | ||
341 | bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start; | ||
342 | 323 | ||
343 | #ifdef CONFIG_HIGHMEM | 324 | #ifdef CONFIG_HIGHMEM |
344 | { | 325 | { |
@@ -348,13 +329,9 @@ void __init mem_init(void) | |||
348 | for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { | 329 | for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { |
349 | phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT; | 330 | phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT; |
350 | struct page *page = pfn_to_page(pfn); | 331 | struct page *page = pfn_to_page(pfn); |
351 | if (memblock_is_reserved(paddr)) | 332 | if (!memblock_is_reserved(paddr)) |
352 | continue; | 333 | free_highmem_page(page); |
353 | free_highmem_page(page); | ||
354 | reservedpages--; | ||
355 | } | 334 | } |
356 | printk(KERN_DEBUG "High memory: %luk\n", | ||
357 | totalhigh_pages << (PAGE_SHIFT-10)); | ||
358 | } | 335 | } |
359 | #endif /* CONFIG_HIGHMEM */ | 336 | #endif /* CONFIG_HIGHMEM */ |
360 | 337 | ||
@@ -367,16 +344,7 @@ void __init mem_init(void) | |||
367 | (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1; | 344 | (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1; |
368 | #endif | 345 | #endif |
369 | 346 | ||
370 | printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, " | 347 | mem_init_print_info(NULL); |
371 | "%luk reserved, %luk data, %luk bss, %luk init)\n", | ||
372 | nr_free_pages() << (PAGE_SHIFT-10), | ||
373 | num_physpages << (PAGE_SHIFT-10), | ||
374 | codesize >> 10, | ||
375 | reservedpages << (PAGE_SHIFT-10), | ||
376 | datasize >> 10, | ||
377 | bsssize >> 10, | ||
378 | initsize >> 10); | ||
379 | |||
380 | #ifdef CONFIG_PPC32 | 348 | #ifdef CONFIG_PPC32 |
381 | pr_info("Kernel virtual memory layout:\n"); | 349 | pr_info("Kernel virtual memory layout:\n"); |
382 | pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP); | 350 | pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP); |