linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, rppt@kernel.org,
	Baoquan He <bhe@redhat.com>
Subject: [PATCH] mm/page.c: move mem_init_print_info() to later place
Date: Wed, 22 Nov 2023 12:35:50 +0800	[thread overview]
Message-ID: <20231122043550.489889-1-bhe@redhat.com> (raw)

Currently if CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, only part of
pages are initialized and added into buddy allocator at early stage. Then
the system memory information printed by mem_init_print_info() is
incorrect. The snippets of boot log are pasted here:
-----------------------------------------------------------------------
[    0.059606] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.059622] software IO TLB: area num 64.
[    0.143887] Memory: 1767888K/133954872K available (20480K kernel code, 3284K rwdata, 8972K rodata, 4572K init, 4916K bss, 2529756K reserved, 0K cma-reserved)
[    0.145111] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=64, Nodes=2
---------------------------------------------------------------------------

Here, move mem_init_print_info() to later place until page init is
finished. After the fix, the printed memory information is like this:
-------------------------------------------------------------------------
[  +0.001002] smpboot: Total of 64 processors activated (293724.92 BogoMIPS)
[  +0.050086] node 0 deferred pages initialised in 45ms
[  +0.007309] node 1 deferred pages initialised in 53ms
[    4.035449] Memory: 131272772K/133954872K available (20480K kernel code, 3284K rwdata, 8972K rodata, 4572K init, 4916K bss, 2529700K reserved, 0K cma-reserved)
[  +0.015995] devtmpfs: initialized
[  +0.003943] x86/mm: Memory block size: 2048MB
-------------------------------------------------------------------------

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 include/linux/gfp.h | 1 +
 init/main.c         | 1 +
 mm/mm_init.c        | 3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index de292a007138..2d69fa59b489 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -335,6 +335,7 @@ void drain_local_pages(struct zone *zone);
 
 void page_alloc_init_late(void);
 void setup_pcp_cacheinfo(void);
+void mem_init_print_info(void);
 
 /*
  * gfp_allowed_mask is set to GFP_BOOT_MASK during early boot to restrict what
diff --git a/init/main.c b/init/main.c
index e24b0780fdff..88f238a478a1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1547,6 +1547,7 @@ static noinline void __init kernel_init_freeable(void)
 	workqueue_init_topology();
 	padata_init();
 	page_alloc_init_late();
+	mem_init_print_info();
 
 	do_basic_setup();
 
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 077bfe393b5e..d08f7c7f75f1 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2703,7 +2703,7 @@ static void __init report_meminit(void)
 		pr_info("mem auto-init: clearing system memory may take some time...\n");
 }
 
-static void __init mem_init_print_info(void)
+void __init mem_init_print_info(void)
 {
 	unsigned long physpages, codesize, datasize, rosize, bss_size;
 	unsigned long init_code_size, init_data_size;
@@ -2774,7 +2774,6 @@ void __init mm_core_init(void)
 	kmsan_init_shadow();
 	stack_depot_early_init();
 	mem_init();
-	mem_init_print_info();
 	kmem_cache_init();
 	/*
 	 * page_owner must be initialized after buddy is ready, and also after
-- 
2.41.0



             reply	other threads:[~2023-11-22  4:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22  4:35 Baoquan He [this message]
2023-11-22 15:08 ` Mike Rapoport
2023-11-24  7:31   ` Baoquan He

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=20231122043550.489889-1-bhe@redhat.com \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    /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