From: Jaewon Kim <jaewon31.kim@samsung.com>
To: rppt@kernel.org, vbabka@suse.cz, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
ytk.lee@samsung.com, jaewon31.kim@gmail.com,
Jaewon Kim <jaewon31.kim@samsung.com>
Subject: [PATCH 8/8] memblock: print kernel internal size
Date: Thu, 24 Mar 2022 16:01:58 +0900 [thread overview]
Message-ID: <20220324070158.22969-9-jaewon31.kim@samsung.com> (raw)
In-Reply-To: <20220324070158.22969-1-jaewon31.kim@samsung.com>
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(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7a3dd7e617e4..6b874c602b3b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -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 */
diff --git a/mm/memblock.c b/mm/memblock.c
index ef8cec6242d2..083d19b1d061 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -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",
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bbbe314850b0..2bf75ba3c66d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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;
--
2.17.1
next prev parent reply other threads:[~2022-03-24 7:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220324065919epcas1p4c79da5f6ec4fa0311409ca24a38785d8@epcas1p4.samsung.com>
2022-03-24 7:01 ` [PATCH 0/8] memblock: introduce memsize showing reserved memory Jaewon Kim
[not found] ` <CGME20220324065919epcas1p35bafcd9151cf0469e4e933250c491a88@epcas1p3.samsung.com>
2022-03-24 7:01 ` [PATCH 1/8] " Jaewon Kim
[not found] ` <CGME20220324065919epcas1p1b30eabc8bbe01da1ef90280b6ee8bcea@epcas1p1.samsung.com>
2022-03-24 7:01 ` [PATCH 2/8] memblock: detect hidden memory hole size Jaewon Kim
[not found] ` <CGME20220324065919epcas1p3429ec2c9595c54ffe4ee25f273febd1c@epcas1p3.samsung.com>
2022-03-24 7:01 ` [PATCH 3/8] memblock: handle overlapped reserved memory region Jaewon Kim
[not found] ` <CGME20220324065919epcas1p256ff799f37a765a432475808e708d639@epcas1p2.samsung.com>
2022-03-24 7:01 ` [PATCH 4/8] memblock: track memblock changed at early param Jaewon Kim
[not found] ` <CGME20220324065919epcas1p3a3a267c4348be4fd3bb8437d4e6db142@epcas1p3.samsung.com>
2022-03-24 7:01 ` [PATCH 5/8] memblock: track kernel size on memsize Jaewon Kim
[not found] ` <CGME20220324065919epcas1p1058e2841b009d8c7d683bc0408f8a5a4@epcas1p1.samsung.com>
2022-03-24 7:01 ` [PATCH 6/8] memblock: recognize late free by checking PageReserved Jaewon Kim
[not found] ` <CGME20220324065919epcas1p4b935c884aa3fde0917f6dff8bff128ed@epcas1p4.samsung.com>
2022-03-24 7:01 ` [PATCH 7/8] memblock: print memsize summary information Jaewon Kim
[not found] ` <CGME20220324065919epcas1p46b5381b1b839d7076673c23e8f9b0bba@epcas1p4.samsung.com>
2022-03-24 7:01 ` Jaewon Kim [this message]
2022-03-25 7:46 ` [PATCH 0/8] memblock: introduce memsize showing reserved memory Mike Rapoport
[not found] ` <CGME20220324065919epcas1p4c79da5f6ec4fa0311409ca24a38785d8@epcms1p3>
2022-03-25 8:38 ` Jaewon Kim
2022-03-27 7:40 ` Mike Rapoport
[not found] ` <CGME20220324065919epcas1p4c79da5f6ec4fa0311409ca24a38785d8@epcms1p1>
2022-03-27 13:53 ` Jaewon Kim
2022-03-27 15:15 ` Mike Rapoport
[not found] ` <CGME20220324065919epcas1p4c79da5f6ec4fa0311409ca24a38785d8@epcms1p7>
2022-03-29 2:46 ` Jaewon Kim
2022-03-30 7:08 ` Mike Rapoport
[not found] ` <CGME20220324065919epcas1p4c79da5f6ec4fa0311409ca24a38785d8@epcms1p8>
2022-03-30 7:22 ` Jaewon Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220324070158.22969-9-jaewon31.kim@samsung.com \
--to=jaewon31.kim@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=jaewon31.kim@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
--cc=vbabka@suse.cz \
--cc=ytk.lee@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).