@@ -3387,4 +3387,7 @@ madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
}
#endif
+extern unsigned long physpages, codesize, datasize, rosize, bss_size;
+extern unsigned long init_code_size, init_data_size;
+
#endif /* _LINUX_MM_H */
@@ -2494,6 +2494,13 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
struct memsize_rgn_struct *rgn;
unsigned long reserved = 0, reusable = 0, total;
unsigned long system = totalram_pages() << PAGE_SHIFT;
+ unsigned long text, rw, ro, bss, etc;
+
+ text = codesize;
+ rw = datasize;
+ ro = rosize;
+ bss = bss_size;
+ etc = kernel_init_size - text - rw - ro - bss;
sort(memsize_rgn, memsize_rgn_count,
sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
@@ -2526,6 +2533,16 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
DIV_ROUND_UP(kernel_init_size + reserved, SZ_1K));
seq_printf(m, " .kernel : %7lu KB\n",
DIV_ROUND_UP(kernel_init_size, SZ_1K));
+ seq_printf(m, " .text : %7lu KB\n"
+ " .rwdata : %7lu KB\n"
+ " .rodata : %7lu KB\n"
+ " .bss : %7lu KB\n"
+ " .etc : %7lu KB\n",
+ DIV_ROUND_UP(text, SZ_1K),
+ DIV_ROUND_UP(rw, SZ_1K),
+ DIV_ROUND_UP(ro, SZ_1K),
+ DIV_ROUND_UP(bss, SZ_1K),
+ DIV_ROUND_UP(etc, SZ_1K));
seq_printf(m, " .unusable : %7lu KB\n",
DIV_ROUND_UP(reserved, SZ_1K));
seq_printf(m, "System : %7lu KB\n",
@@ -8243,11 +8243,11 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char
return pages;
}
+unsigned long physpages, codesize, datasize, rosize, bss_size;
+unsigned long init_code_size, init_data_size;
+
void __init mem_init_print_info(void)
{
- unsigned long physpages, codesize, datasize, rosize, bss_size;
- unsigned long init_code_size, init_data_size;
-
physpages = get_num_physpages();
codesize = _etext - _stext;
datasize = _edata - _sdata;
Kernel internal size information is also useful to compare with other binary. This patch print kernel text, rwdata, rodata, bss, and others. Here's an example. Reserved : 746924 KB .kernel : 137027 KB .text : 28158 KB .rwdata : 3238 KB .rodata : 13468 KB .bss : 12570 KB .etc : 79593 KB .unusable : 609897 KB System : 3447380 KB .common : 3152468 KB .reusable : 294912 KB Total : 4194304 KB ( 4096.00 MB ) Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com> --- include/linux/mm.h | 3 +++ mm/memblock.c | 17 +++++++++++++++++ mm/page_alloc.c | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-)