public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH] mm: Mark early-init static variables with __meminitdata
@ 2026-03-21 12:08 Chengkaitao
  0 siblings, 0 replies; only message in thread
From: Chengkaitao @ 2026-03-21 12:08 UTC (permalink / raw)
  To: rppt, akpm, david, ljs, Liam.Howlett, vbabka, surenb, mhocko
  Cc: linux-mm, linux-kernel, Kaitao Cheng

From: Kaitao Cheng <chengkaitao@kylinos.cn>

Static variables defined inside __meminit functions should also be
marked with __meminitdata, so that their storage is placed in the
.init.data section and reclaimed with free_initmem(), thereby
reducing permanent .bss memory usage when CONFIG_MEMORY_HOTPLUG is
disabled.

Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
 mm/mm_init.c        | 2 +-
 mm/sparse-vmemmap.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index df34797691bd..24420217522f 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -801,7 +801,7 @@ void __meminit reserve_bootmem_region(phys_addr_t start,
 static bool __meminit
 overlap_memmap_init(unsigned long zone, unsigned long *pfn)
 {
-	static struct memblock_region *r;
+	static struct memblock_region *r __meminitdata;
 
 	if (mirrored_kernelcore && zone == ZONE_MOVABLE) {
 		if (!r || *pfn >= memblock_region_memory_end_pfn(r)) {
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 37522d6cb398..ca05941463f4 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -62,7 +62,7 @@ void * __meminit vmemmap_alloc_block(unsigned long size, int node)
 	if (slab_is_available()) {
 		gfp_t gfp_mask = GFP_KERNEL|__GFP_RETRY_MAYFAIL|__GFP_NOWARN;
 		int order = get_order(size);
-		static bool warned;
+		static bool warned __meminitdata;
 		struct page *page;
 
 		page = alloc_pages_node(node, gfp_mask, order);
-- 
2.50.1 (Apple Git-155)



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-21 12:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 12:08 [PATCH] mm: Mark early-init static variables with __meminitdata Chengkaitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox