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,
jaewon31.kim@gmail.com, Jaewon Kim <jaewon31.kim@samsung.com>
Subject: [RESEND PATCH 09/10] memblock: print kernel internal size
Date: Tue, 21 May 2024 11:39:56 +0900 [thread overview]
Message-ID: <20240521023957.2587005-10-jaewon31.kim@samsung.com> (raw)
In-Reply-To: <20240521023957.2587005-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 : 1181708 KB
.kernel : 296172 KB
.text : 16960 KB
.rwdata : 2299 KB
.rodata : 16464 KB
.bss : 7549 KB
.memmap : 196608 KB
.etc : 56293 KB
.unusable : 885536 KB
Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
---
include/linux/memblock.h | 6 ++++++
mm/memblock.c | 36 ++++++++++++++++++++++++++++++++++++
mm/mm_init.c | 6 +++++-
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index a83ad98ac252..7ab8b59bfbc1 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -623,6 +623,9 @@ extern void memblock_memsize_unset_name(void);
extern void memblock_memsize_enable_tracking(void);
extern void memblock_memsize_disable_tracking(void);
extern void memblock_memsize_mod_kernel_size(long size);
+extern void memblock_memsize_mod_memmap_size(long size);
+extern void memblock_memsize_kernel_code_data(unsigned long code,
+ unsigned long data, unsigned long ro, unsigned long bss);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
@@ -633,6 +636,9 @@ static inline void memblock_memsize_unset_name(void) { }
static inline void memblock_memsize_enable_tracking(void){ }
static inline void memblock_memsize_disable_tracking(void){ }
static inline void memblock_memsize_mod_kernel_size(long size) { }
+static inline void memblock_memsize_mod_memmap_size(long size) { }
+static inline void memblock_memsize_kernel_code_data(unsigned long code,
+ unsigned long data, unsigned long ro, unsigned long bss) { }
#endif
#endif /* _LINUX_MEMBLOCK_H */
diff --git a/mm/memblock.c b/mm/memblock.c
index 0906d81f66c2..2fe0dc2575c5 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2061,6 +2061,11 @@ static struct memsize_rgn_struct memsize_rgn[CONFIG_MAX_MEMBLOCK_MEMSIZE] __init
static int memsize_rgn_count __initdata_memblock;
static const char *memblock_memsize_name __initdata_memblock;
static long memsize_kinit __initdata_memblock;
+static long memsize_memap __initdata_memblock;
+static unsigned long memsize_code __initdata_memblock;
+static unsigned long memsize_data __initdata_memblock;
+static unsigned long memsize_ro __initdata_memblock;
+static unsigned long memsize_bss __initdata_memblock;
static bool memblock_memsize_tracking __initdata_memblock = true;
void __init memblock_memsize_enable_tracking(void)
@@ -2073,11 +2078,25 @@ void __init memblock_memsize_disable_tracking(void)
memblock_memsize_tracking = false;
}
+void __init memblock_memsize_mod_memmap_size(long size)
+{
+ memsize_memap += size;
+}
+
void memblock_memsize_mod_kernel_size(long size)
{
memsize_kinit += size;
}
+void __init memblock_memsize_kernel_code_data(unsigned long code, unsigned long data,
+ unsigned long ro, unsigned long bss)
+{
+ memsize_code = code;
+ memsize_data = data;
+ memsize_ro = ro;
+ memsize_bss = bss;
+}
+
static void __init_memblock memsize_get_valid_name(char *valid_name, const char *name)
{
char *head, *tail, *found;
@@ -2691,6 +2710,11 @@ 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 etc;
+
+ etc = memsize_kinit;
+ etc -= memsize_code + memsize_data + memsize_ro + memsize_bss +
+ memsize_memap;
sort(memsize_rgn, memsize_rgn_count,
sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
@@ -2723,6 +2747,18 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
DIV_ROUND_UP(memsize_kinit + reserved, SZ_1K));
seq_printf(m, " .kernel : %7lu KB\n",
DIV_ROUND_UP(memsize_kinit, SZ_1K));
+ seq_printf(m, " .text : %7lu KB\n"
+ " .rwdata : %7lu KB\n"
+ " .rodata : %7lu KB\n"
+ " .bss : %7lu KB\n"
+ " .memmap : %7lu KB\n"
+ " .etc : %7lu KB\n",
+ DIV_ROUND_UP(memsize_code, SZ_1K),
+ DIV_ROUND_UP(memsize_data, SZ_1K),
+ DIV_ROUND_UP(memsize_ro, SZ_1K),
+ DIV_ROUND_UP(memsize_bss, SZ_1K),
+ DIV_ROUND_UP(memsize_memap, 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/mm_init.c b/mm/mm_init.c
index f72b852bd5b8..45187904db49 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1587,8 +1587,10 @@ void __init *memmap_alloc(phys_addr_t size, phys_addr_t align,
MEMBLOCK_ALLOC_ACCESSIBLE,
nid);
- if (ptr && size > 0)
+ if (ptr && size > 0) {
page_init_poison(ptr, size);
+ memblock_memsize_mod_memmap_size((long)size);
+ }
return ptr;
}
@@ -2679,6 +2681,8 @@ static void __init mem_init_print_info(void)
init_data_size = __init_end - __init_begin;
init_code_size = _einittext - _sinittext;
+ memblock_memsize_kernel_code_data(codesize, datasize, rosize, bss_size);
+
/*
* Detect special cases and adjust section sizes accordingly:
* 1) .init.* may be embedded into .data sections
--
2.25.1
next prev parent reply other threads:[~2024-05-21 2:40 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcas1p1.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory Jaewon Kim
[not found] ` <CGME20240521024009epcas1p4451928c8f5b32bf84082a24c59ca7dd0@epcas1p4.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 01/10] " Jaewon Kim
[not found] ` <CGME20240521024009epcas1p3e80e90863a453053d5aac901ef644070@epcas1p3.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 02/10] memblock: detect hidden memory hole size Jaewon Kim
[not found] ` <CGME20240521024009epcas1p152671a613e86fa83d840962ee3db50fb@epcas1p1.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 03/10] memblock: handle overlapped reserved memory region Jaewon Kim
[not found] ` <CGME20240521024009epcas1p3440f857e3b31b319c270e2d658379383@epcas1p3.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 04/10] memblock: take a region intersecting an unknown region Jaewon Kim
[not found] ` <CGME20240521024009epcas1p20ddcabed3d037904a9c651d27f82c077@epcas1p2.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 05/10] memblock: track memblock changed at early param Jaewon Kim
[not found] ` <CGME20240521024009epcas1p40d0ea59e8ae93f6cc89846626fea4207@epcas1p4.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 06/10] memblock: recognize late freed size by checking PageReserved Jaewon Kim
[not found] ` <CGME20240521024009epcas1p3ccda7b2d9e6518b4575427c957e19377@epcas1p3.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 07/10] memblock: track kernel size on memsize Jaewon Kim
2024-05-22 19:03 ` kernel test robot
[not found] ` <CGME20240521024009epcas1p291bbc11c4e5cdaa922ca302d95330e6b@epcas1p2.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 08/10] memblock: print memsize summary information Jaewon Kim
[not found] ` <CGME20240521024009epcas1p441a4c458d251eec7bb6e63e671c25b4e@epcas1p4.samsung.com>
2024-05-21 2:39 ` Jaewon Kim [this message]
2024-05-22 18:52 ` [RESEND PATCH 09/10] memblock: print kernel internal size kernel test robot
[not found] ` <CGME20240521024009epcas1p15a3290b675ee66339033c185a5a8c00b@epcas1p1.samsung.com>
2024-05-21 2:39 ` [RESEND PATCH 10/10] memblock: support memsize reusable to consider as reusable Jaewon Kim
2024-05-22 22:40 ` kernel test robot
[not found] ` <CGME20240522224129epcas1p10433785cc14bef5de93e9f26aa599ff0@epcms1p8>
2024-05-23 10:55 ` Jaewon Kim
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p6>
2024-05-21 2:53 ` [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory Jaewon Kim
2024-05-21 7:31 ` Mike Rapoport
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p5>
2024-05-21 10:17 ` Jaewon Kim
2024-05-22 8:16 ` (2) " Wei Yang
2024-05-23 14:34 ` Mike Rapoport
2024-05-24 17:33 ` Pintu Agarwal
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p8>
2024-05-22 8:47 ` Jaewon Kim
2024-05-23 8:55 ` Wei Yang
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p2>
2024-05-23 9:23 ` 김재원
2024-05-24 9:07 ` (2) " Jaewon Kim
2024-05-26 13:55 ` Mike Rapoport
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p7>
2024-05-27 1:30 ` Jaewon Kim
[not found] ` <20240529095119epcms1p73f0e9ff756bcb2ee6a14db459128a644@epcms1p7>
2024-05-29 11:35 ` Wei Yang
2024-05-29 13:10 ` Jaewon Kim
2024-05-30 0:03 ` Wei Yang
2024-05-27 1:35 ` Jaewon Kim
2024-05-27 16:22 ` Mike Rapoport
2024-05-30 10:49 ` Jaewon Kim
2024-05-31 1:05 ` (2) " Wei Yang
[not found] ` <CGME20240521024009epcas1p10ed9f9b929203183a29f79508e79bb76@epcms1p4>
2024-05-31 8:21 ` Jaewon Kim
2024-06-01 1:40 ` Wei Yang
2024-06-03 9:33 ` Jaewon Kim
2024-05-22 8:20 ` Wei Yang
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=20240521023957.2587005-10-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 \
/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