]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: mark early-init static variables with __meminitdata
authorKaitao Cheng <chengkaitao@kylinos.cn>
Sat, 21 Mar 2026 12:08:47 +0000 (20:08 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:34 +0000 (13:53 -0700)
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.

Link: https://lkml.kernel.org/r/20260321120847.8159-1-pilgrimtao@gmail.com
Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mm_init.c
mm/sparse-vmemmap.c

index 4324b93ccebdb337b4459de741eaae973d3d3985..79f93f2a90cf2e4c0fc42678fd02b85e45494402 100644 (file)
@@ -812,7 +812,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)) {
index 24a37676cecbb1037d6e7900b75b52586a5dad51..6eadb9d116e4338603f5372dd7fbf675c82560de 100644 (file)
@@ -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);