diff options
author | Jiang Liu <liuj97@gmail.com> | 2013-07-03 18:03:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:35 -0400 |
commit | bee4ebd117ac943308dd57bc0a5a3cc539f0eaac (patch) | |
tree | 5e35784c6797195d5b800bdae8dd3ef3d7d03e4e /arch/arm64 | |
parent | 2450c97323e635a04f7b2f4b68680ab2c151bbbf (diff) |
mm/ARM64: 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: Russell King <linux@arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/mm/init.c | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 93de98afedd7..b16c778ea0de 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
@@ -272,59 +272,17 @@ static void __init free_unused_memmap(void) | |||
272 | */ | 272 | */ |
273 | void __init mem_init(void) | 273 | void __init mem_init(void) |
274 | { | 274 | { |
275 | unsigned long reserved_pages, free_pages; | ||
276 | struct memblock_region *reg; | ||
277 | |||
278 | arm64_swiotlb_init(); | 275 | arm64_swiotlb_init(); |
279 | 276 | ||
280 | max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; | 277 | max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; |
281 | 278 | ||
282 | #ifndef CONFIG_SPARSEMEM_VMEMMAP | 279 | #ifndef CONFIG_SPARSEMEM_VMEMMAP |
283 | /* this will put all unused low memory onto the freelists */ | ||
284 | free_unused_memmap(); | 280 | free_unused_memmap(); |
285 | #endif | 281 | #endif |
286 | 282 | /* this will put all unused low memory onto the freelists */ | |
287 | free_all_bootmem(); | 283 | free_all_bootmem(); |
288 | 284 | ||
289 | reserved_pages = free_pages = 0; | 285 | mem_init_print_info(); |
290 | |||
291 | for_each_memblock(memory, reg) { | ||
292 | unsigned int pfn1, pfn2; | ||
293 | struct page *page, *end; | ||
294 | |||
295 | pfn1 = __phys_to_pfn(reg->base); | ||
296 | pfn2 = pfn1 + __phys_to_pfn(reg->size); | ||
297 | |||
298 | page = pfn_to_page(pfn1); | ||
299 | end = pfn_to_page(pfn2 - 1) + 1; | ||
300 | |||
301 | do { | ||
302 | if (PageReserved(page)) | ||
303 | reserved_pages++; | ||
304 | else if (!page_count(page)) | ||
305 | free_pages++; | ||
306 | page++; | ||
307 | } while (page < end); | ||
308 | } | ||
309 | |||
310 | /* | ||
311 | * Since our memory may not be contiguous, calculate the real number | ||
312 | * of pages we have in this system. | ||
313 | */ | ||
314 | pr_info("Memory:"); | ||
315 | num_physpages = 0; | ||
316 | for_each_memblock(memory, reg) { | ||
317 | unsigned long pages = memblock_region_memory_end_pfn(reg) - | ||
318 | memblock_region_memory_base_pfn(reg); | ||
319 | num_physpages += pages; | ||
320 | printk(" %ldMB", pages >> (20 - PAGE_SHIFT)); | ||
321 | } | ||
322 | printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT)); | ||
323 | |||
324 | pr_notice("Memory: %luk/%luk available, %luk reserved\n", | ||
325 | nr_free_pages() << (PAGE_SHIFT-10), | ||
326 | free_pages << (PAGE_SHIFT-10), | ||
327 | reserved_pages << (PAGE_SHIFT-10)); | ||
328 | 286 | ||
329 | #define MLK(b, t) b, t, ((t) - (b)) >> 10 | 287 | #define MLK(b, t) b, t, ((t) - (b)) >> 10 |
330 | #define MLM(b, t) b, t, ((t) - (b)) >> 20 | 288 | #define MLM(b, t) b, t, ((t) - (b)) >> 20 |
@@ -366,7 +324,7 @@ void __init mem_init(void) | |||
366 | BUILD_BUG_ON(TASK_SIZE_64 > MODULES_VADDR); | 324 | BUILD_BUG_ON(TASK_SIZE_64 > MODULES_VADDR); |
367 | BUG_ON(TASK_SIZE_64 > MODULES_VADDR); | 325 | BUG_ON(TASK_SIZE_64 > MODULES_VADDR); |
368 | 326 | ||
369 | if (PAGE_SIZE >= 16384 && num_physpages <= 128) { | 327 | if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { |
370 | extern int sysctl_overcommit_memory; | 328 | extern int sysctl_overcommit_memory; |
371 | /* | 329 | /* |
372 | * On a machine this small we won't get anywhere without | 330 | * On a machine this small we won't get anywhere without |