aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorJiang Liu <liuj97@gmail.com>2013-07-03 18:03:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:35 -0400
commit7ee3d4e8cd560500192d80ca84d7f15d6dee0807 (patch)
tree8c58a121edb9c528fb6497e04774dca8d121aa4f /mm/page_alloc.c
parenta214a8c68bcdef2fb0803425f7fe36fe41030d3f (diff)
mm: introduce helper function mem_init_print_info() to simplify mem_init()
Introduce helper function mem_init_print_info() to simplify mem_init() across different architectures, which also unifies the format and information printed. Function mem_init_print_info() calculates memory statistics information without walking each page, so it should be a little faster on some architectures. Also introduce another helper get_num_physpages() to kill the global variable num_physpages. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Michel Lespinasse <walken@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d9445c4f5fd7..327516b7aee9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -61,6 +61,7 @@
61#include <linux/hugetlb.h> 61#include <linux/hugetlb.h>
62#include <linux/sched/rt.h> 62#include <linux/sched/rt.h>
63 63
64#include <asm/sections.h>
64#include <asm/tlbflush.h> 65#include <asm/tlbflush.h>
65#include <asm/div64.h> 66#include <asm/div64.h>
66#include "internal.h" 67#include "internal.h"
@@ -5246,6 +5247,57 @@ void free_highmem_page(struct page *page)
5246} 5247}
5247#endif 5248#endif
5248 5249
5250
5251void __init mem_init_print_info(const char *str)
5252{
5253 unsigned long physpages, codesize, datasize, rosize, bss_size;
5254 unsigned long init_code_size, init_data_size;
5255
5256 physpages = get_num_physpages();
5257 codesize = _etext - _stext;
5258 datasize = _edata - _sdata;
5259 rosize = __end_rodata - __start_rodata;
5260 bss_size = __bss_stop - __bss_start;
5261 init_data_size = __init_end - __init_begin;
5262 init_code_size = _einittext - _sinittext;
5263
5264 /*
5265 * Detect special cases and adjust section sizes accordingly:
5266 * 1) .init.* may be embedded into .data sections
5267 * 2) .init.text.* may be out of [__init_begin, __init_end],
5268 * please refer to arch/tile/kernel/vmlinux.lds.S.
5269 * 3) .rodata.* may be embedded into .text or .data sections.
5270 */
5271#define adj_init_size(start, end, size, pos, adj) \
5272 if (start <= pos && pos < end && size > adj) \
5273 size -= adj;
5274
5275 adj_init_size(__init_begin, __init_end, init_data_size,
5276 _sinittext, init_code_size);
5277 adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size);
5278 adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size);
5279 adj_init_size(_stext, _etext, codesize, __start_rodata, rosize);
5280 adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize);
5281
5282#undef adj_init_size
5283
5284 printk("Memory: %luK/%luK available "
5285 "(%luK kernel code, %luK rwdata, %luK rodata, "
5286 "%luK init, %luK bss, %luK reserved"
5287#ifdef CONFIG_HIGHMEM
5288 ", %luK highmem"
5289#endif
5290 "%s%s)\n",
5291 nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
5292 codesize >> 10, datasize >> 10, rosize >> 10,
5293 (init_data_size + init_code_size) >> 10, bss_size >> 10,
5294 (physpages - totalram_pages) << (PAGE_SHIFT-10),
5295#ifdef CONFIG_HIGHMEM
5296 totalhigh_pages << (PAGE_SHIFT-10),
5297#endif
5298 str ? ", " : "", str ? str : "");
5299}
5300
5249/** 5301/**
5250 * set_dma_reserve - set the specified number of pages reserved in the first zone 5302 * set_dma_reserve - set the specified number of pages reserved in the first zone
5251 * @new_dma_reserve: The number of pages to mark reserved 5303 * @new_dma_reserve: The number of pages to mark reserved