mm: split a couple of headers from internal.h
Subsystems (13)
Mike Rapoport (Microsoft)
maintainercover mm: split a couple of headers from internal.h
mm/internal.h becomes more and more bloated.
Split declarations related to mm_init, memblock, vmalloc and sparse into new headers.
---
Mike Rapoport (Microsoft) (3):
mm: split out mm_init and memblock declarations from internal.h
mm: split out sparse declarations from internal.h
mm: split out vmalloc declarations from internal.h
MAINTAINERS | 3 + kernel/liveupdate/kexec_handover.c | 3 +- mm/cma.c | 1 + mm/execmem.c | 1 + mm/hugetlb.c | 1 + mm/internal.h | 183 ------------------------------------- mm/kmsan/hooks.c | 1 + mm/kmsan/shadow.c | 1 + mm/memblock.c | 1 + mm/memory_hotplug.c | 1 + mm/mm_init.c | 3 + mm/mm_init.h | 120 ++++++++++++++++++++++++ mm/page_alloc.c | 1 + mm/percpu-vm.c | 1 + mm/sparse-vmemmap.c | 2 + mm/sparse.c | 2 + mm/sparse.h | 63 +++++++++++++ mm/vmalloc.c | 1 + mm/vmalloc.h | 46 ++++++++++ 19 files changed, 251 insertions(+), 184 deletions(-)
---
base-commit: 820d5dfede0cd55dcbc89ce96fcfbb11b7c457ba
change-id: 20260707-internal-h-2efef660381d
--
Sincerely yours,
Mike.
Mike Rapoport (Microsoft)
maintainerPATCH 1/3 mm: split out mm_init and memblock declarations from internal.h
mm/internal.h becomes more and more bloated.
Move declarations for related to mm/mm_init.c and mm/memblock.c to a new mm/mm_init.h header.
No functional changes.
--- MAINTAINERS | 1 + kernel/liveupdate/kexec_handover.c | 1 + mm/cma.c | 1 + mm/hugetlb.c | 1 + mm/internal.h | 91 ---------------------------- mm/memblock.c | 1 + mm/memory_hotplug.c | 1 + mm/mm_init.c | 1 + mm/mm_init.h | 120 +++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 1 + mm/sparse-vmemmap.c | 1 + 11 files changed, 129 insertions(+), 91 deletions(-)
MAINTAINERS +1 -0
@@ -16882,6 +16882,7 @@ F: mm/bootmem_info.c F: mm/memblock.c F: mm/memtest.c F: mm/mm_init.c +F: mm/mm_init.h F: mm/rodata_test.c F: tools/testing/memblock/
kernel/liveupdate/kexec_handover.c +1 -0
@@ -35,6 +35,7 @@* internal APIs. */ #include "../../mm/internal.h" +#include "../../mm/mm_init.h" #include "../kexec_internal.h" #include "kexec_handover_internal.h"
mm/cma.c +1 -0
@@ -33,6 +33,7 @@#include "internal.h" #include "cma.h" +#include "mm_init.h" struct cma cma_areas[MAX_CMA_AREAS ];unsigned int cma_area_count;
mm/hugetlb.c +1 -0
@@ -51,6 +51,7 @@#include "hugetlb_vmemmap.h" #include "hugetlb_cma.h" #include "hugetlb_internal.h" +#include "mm_init.h" #include <linux/page-isolation.h> int hugetlb_max_hstate__read_mostly ;
mm/internal.h +0 -91
148 lines not on this page · raw message
mm/memblock.c +1 -0
@@ -29,6 +29,7 @@#include <linux/io.h> #include "internal.h" +#include "mm_init.h" #define INIT_MEMBLOCK_REGIONS 128#define INIT_PHYSMEM_REGIONS 4
mm/memory_hotplug.c +1 -0
@@ -40,6 +40,7 @@#include <asm/tlbflush.h> #include "internal.h" +#include "mm_init.h" #include "page_alloc.h" #include "shuffle.h"
mm/mm_init.c +1 -0
@@ -33,6 +33,7 @@#include <linux/kexec_handover.h> #include <linux/hugetlb.h> #include "internal.h" +#include "mm_init.h" #include "page_alloc.h" #include "slab.h" #include "shuffle.h"
mm/mm_init.h new file +120 -0
120 lines not on this page · raw message
mm/page_alloc.c +1 -0
@@ -56,6 +56,7 @@#include <linux/pgalloc_tag.h> #include <asm/div64.h> #include "internal.h" +#include "mm_init.h" #include "page_alloc.h" #include "shuffle.h" #include "page_reporting.h"
mm/sparse-vmemmap.c +1 -0
@@ -41,6 +41,7 @@#define VMEMMAP_POPULATE_PAGEREF 0x0001#include "internal.h" +#include "mm_init.h" /* * Allocate a block of memory to be used to back the virtual memory map
Signature · 1 line
2.53.0
Mike Rapoport (Microsoft)
maintainerPATCH 2/3 mm: split out sparse declarations from internal.h
In reply to Mike Rapoport (Microsoft)mm/internal.h becomes more and more bloated.
Move declarations related to SPARSE and SPARSE_VMEMMAP memory models to a new mm/sparse.h header.
No functional changes.
--- MAINTAINERS | 1 + mm/internal.h | 52 ------------------------------------------- mm/mm_init.c | 1 + mm/sparse-vmemmap.c | 1 + mm/sparse.c | 2 ++ mm/sparse.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 52 deletions(-)
MAINTAINERS +1 -0
@@ -16999,6 +16999,7 @@ F: mm/pgtable-generic.c F: mm/ptdump.c F: mm/sparse-vmemmap.c F: mm/sparse.c +F: mm/sparse.h F: mm/util.c F: mm/vmpressure.c F: mm/vmstat.c
mm/internal.h +0 -52
58 lines not on this page · raw message
mm/mm_init.c +1 -0
@@ -35,6 +35,7 @@#include "internal.h" #include "mm_init.h" #include "page_alloc.h" +#include "sparse.h" #include "slab.h" #include "shuffle.h"
mm/sparse-vmemmap.c +1 -0
@@ -42,6 +42,7 @@#include "internal.h" #include "mm_init.h" +#include "sparse.h" /* * Allocate a block of memory to be used to back the virtual memory map
mm/sparse.c +2 -0
@@ -16,6 +16,8 @@#include <linux/bootmem_info.h> #include <linux/vmstat.h> #include "internal.h" +#include "mm_init.h" +#include "sparse.h" #include <asm/dma.h> /*
mm/sparse.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.53.0
Mike Rapoport (Microsoft)
maintainerPATCH 3/3 mm: split out vmalloc declarations from internal.h
In reply to Mike Rapoport (Microsoft)mm/internal.h becomes more and more bloated.
Move declarations related to vmalloc to a new mm/vmalloc.h header.
No functional changes.
--- MAINTAINERS | 1 + kernel/liveupdate/kexec_handover.c | 2 +- mm/execmem.c | 1 + mm/internal.h | 40 --------------------------------- mm/kmsan/hooks.c | 1 + mm/kmsan/shadow.c | 1 + mm/mm_init.c | 1 + mm/percpu-vm.c | 1 + mm/vmalloc.c | 1 + mm/vmalloc.h | 46 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 54 insertions(+), 41 deletions(-)
MAINTAINERS +1 -0
@@ -28813,6 +28813,7 @@ W: http://www.linux-mm.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm F: include/linux/vmalloc.h F: mm/vmalloc.c +F: mm/vmalloc.h F: lib/test_vmalloc.c VME SUBSYSTEM
kernel/liveupdate/kexec_handover.c +1 -1
@@ -34,8 +34,8 @@* KHO is tightly coupled with mm init and needs access to some of mm * internal APIs. */ -#include "../../mm/internal.h" #include "../../mm/mm_init.h" +#include "../../mm/vmalloc.h" #include "../kexec_internal.h" #include "kexec_handover_internal.h"
mm/execmem.c +1 -0
@@ -20,6 +20,7 @@#include <asm/tlbflush.h> #include "internal.h" +#include "vmalloc.h" static struct execmem_info *execmem_info__ro_after_init ;static struct execmem_info default_execmem_info__ro_after_init ;
mm/internal.h +0 -40
@@ -1092,9 +1092,6 @@ static inline void mlock_new_folio(struct folio *folio) { }static inline bool need_mlock_drain (int cpu) {return false; }static inline void mlock_drain_local (void ) { }static inline void mlock_drain_remote (int cpu) { } -static inline void vunmap_range_noflush (unsigned long start,unsigned long end) -{ -}#endif /* !CONFIG_MMU */ #define NODE_RECLAIM_NOSCAN -2
@@ -1209,37 +1206,6 @@ struct migration_target_control {size_t splice_folio_into_pipe (struct pipe_inode_info *pipe,struct folio *folio,loff_t fpos,size_t size); -/* -* mm/vmalloc.c -*/ -#ifdef CONFIG_MMU -void __init vmalloc_init (void ); -int __must_check vmap_pages_range_noflush (unsigned long addr,unsigned long end, -pgprot_t prot,struct page **pages,unsigned int page_shift,gfp_t gfp_mask); -unsigned int get_vm_area_page_order (struct vm_struct *vm); -#else -static inline void vmalloc_init (void ) -{ -} - -static inline -int __must_check vmap_pages_range_noflush (unsigned long addr,unsigned long end, -pgprot_t prot,struct page **pages,unsigned int page_shift,gfp_t gfp_mask) -{ -return -EINVAL ; -} -#endif - -void clear_vm_uninitialized_flag (struct vm_struct *vm); - -int __must_check __vmap_pages_range_noflush (unsigned long addr, -unsigned long end,pgprot_t prot, -struct page **pages,unsigned int page_shift); - -void vunmap_range_noflush (unsigned long start,unsigned long end); - -void __vunmap_range_noflush (unsigned long start,unsigned long end); -static inline bool vma_is_single_threaded_private (struct vm_area_struct *vma) {if (vma->vm_flags &VM_SHARED )
@@ -1267,12 +1233,6 @@ int numa_migrate_check(struct folio *folio, struct vm_fault *vmf,void free_zone_device_folio (struct folio *folio);int migrate_device_coherent_folio (struct folio *folio); -struct vm_struct *__get_vm_area_node (unsigned long size, -unsigned long align,unsigned long shift, -unsigned long vm_flags,unsigned long start, -unsigned long end,int node,gfp_t gfp_mask, -const void *caller); -/* * mm/gup.c */
mm/kmsan/hooks.c +1 -0
@@ -21,6 +21,7 @@#include <linux/usb.h> #include "../internal.h" +#include "../vmalloc.h" #include "../slab.h" #include "kmsan.h"
mm/kmsan/shadow.c +1 -0
@@ -17,6 +17,7 @@#include <linux/stddef.h> #include "../internal.h" +#include "../vmalloc.h" #include "kmsan.h" #define shadow_page_for (page) ((page)->kmsan_shadow)
mm/mm_init.c +1 -0
@@ -38,6 +38,7 @@#include "sparse.h" #include "slab.h" #include "shuffle.h" +#include "vmalloc.h" #include <asm/setup.h>
mm/percpu-vm.c +1 -0
@@ -9,6 +9,7 @@* This is the default chunk allocator. */ #include "internal.h" +#include "vmalloc.h" static struct page *pcpu_chunk_page (struct pcpu_chunk *chunk,unsigned int cpu,int page_idx)
mm/vmalloc.c +1 -0
@@ -49,6 +49,7 @@#include "internal.h" #include "pgalloc-track.h" +#include "vmalloc.h" #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP static unsigned int __ro_after_init ioremap_max_page_shift =BITS_PER_LONG -1 ;
mm/vmalloc.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 1/3] mm: split out mm_init and memblock declarations from internal.h
In reply to Mike Rapoport (Microsoft)Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] Missing semicolon at the end of the `memmap_init_range()` function declaration in the new…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Missing semicolon at the end of the memmap_init_range() function declaration in the new mm/mm_init.h header file.
- [Low] mm/sparse.c fails to compile because it lacks #include "mm_init.h", resulting in undeclared identifiers and potential implicit declarations. --
--- Patch [1]: [PATCH 1/3] mm: split out mm_init and memblock declarations from internal.h --- commit 13783d4d0cf38a0ede9798e1d71f8e2fb2de5d3d
Author: Mike Rapoport (Microsoft) <[email protected]>
mm: split out mm_init and memblock declarations from internal.h
This commit moves declarations related to mm/mm_init.c and mm/memblock.c from mm/internal.h to a new mm/mm_init.h header file to reduce bloat.
Quoted 4 lines
mm/internal.h +0
-0
[ ... ]
mm/internal.h static inline void init_compound_tail(struct page *tail, · line 830
Quoted 12 lines
mm/internal.h +0
-8@@ -820,14 +807,6 @@ static inline void init_compound_tail(struct page *tail,prep_compound_tail (tail, head, order); } -extern void *memmap_alloc (phys_addr_t size,phys_addr_t align, -phys_addr_t min_addr, -int nid,bool exact_nid); - -void memmap_init_range (unsigned long ,int ,unsigned long ,unsigned long , -unsigned long ,enum meminit_context ,struct vmem_altmap *,int , -bool ); -
[Severity: Low]
Since these declarations are moved to mm/mm_init.h, will mm/sparse.c fail to compile? It appears __populate_section_memmap() relies on memmap_alloc(), and mminit_validate_memmodel_limits() relies on mminit_dprintk(), but the patch doesn't add an include for mm_init.h in mm/sparse.c.
Quoted 3 lines
mm/internal.h +0
-0/* * mm/sparse.c */
[ ... ]
Quoted 5 lines
mm/mm_init.h new file +0
-0
[ ... ]
mm/mm_init.h line 41
Quoted 8 lines
mm/mm_init.h new file +8
-0+void *memmap_alloc (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr, +int nid,bool exact_nid); + +void memmap_init_range (unsigned long size,int nid,unsigned long zone, +unsigned long start_pfn,unsigned long zone_end_pfn, +enum meminit_context context, +struct vmem_altmap *altmap,int migratetype, +bool isolate_pageblock)
[Severity: Low]
Does this declaration cause a syntax error because it is missing a semicolon at the end?
Quoted 5 lines
mm/mm_init.h new file +5
-0+ +#if definedCONFIG_COMPACTION || definedCONFIG_CMA +/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ +void init_cma_reserved_pageblock (struct page *page); +#endif
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Mike Rapoport
maintainerRe: [PATCH 1/3] mm: split out mm_init and memblock declarations from internal.h
Quoted 9 lines · On Thu, Jul 09, 2026 at 06:57:12AM +0000, [email protected] wrote:
mm/mm_init.h line 41
Quoted 5 lines
mm/mm_init.h new file +5
-0+void memmap_init_range (unsigned long size,int nid,unsigned long zone, +unsigned long start_pfn,unsigned long zone_end_pfn, +enum meminit_context context, +struct vmem_altmap *altmap,int migratetype, +bool isolate_pageblock)[Severity: Low]
Does this declaration cause a syntax error because it is missing a semicolon at the end?
Fixing checkpatch warning didn't go well :)
Will send v2 later.
Quoted 7 lines
Quoted 4 lines
mm/mm_init.h new file +4
-0+#if definedCONFIG_COMPACTION || definedCONFIG_CMA +/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ +void init_cma_reserved_pageblock (struct page *page); +#endif Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Signature · 2 lines
Sincerely yours, Mike.
Mike Rapoport
maintainerQuoted 4 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.
Sashiko rightfully pointed to some issues, will send v2 later.
Quoted 34 lines
---
Mike Rapoport (Microsoft) (3):
mm: split outmm_initand memblock declarations frominternal.h
mm: split out sparse declarations frominternal.h
mm: split out vmalloc declarations frominternal.hMAINTAINERS | 3 + kernel/liveupdate/kexec_handover.c | 3 +- mm/cma.c | 1 + mm/execmem.c | 1 + mm/hugetlb.c | 1 + mm/internal.h | 183 ------------------------------------- mm/kmsan/hooks.c | 1 + mm/kmsan/shadow.c | 1 + mm/memblock.c | 1 + mm/memory_hotplug.c | 1 + mm/mm_init.c | 3 + mm/mm_init.h | 120 ++++++++++++++++++++++++ mm/page_alloc.c | 1 + mm/percpu-vm.c | 1 + mm/sparse-vmemmap.c | 2 + mm/sparse.c | 2 + mm/sparse.h | 63 +++++++++++++ mm/vmalloc.c | 1 + mm/vmalloc.h | 46 ++++++++++ 19 files changed, 251 insertions(+), 184 deletions(-)---
base-commit:820d5dfede0cd55dcbc89ce96fcfbb11b7c457ba
change-id: 20260707-internal-h-2efef660381d--
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours, Mike.
Quoted 11 lines · Mike Rapoport
Quoted 4 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.Sashiko rightfully pointed to some issues, will send v2 later.
Hi Mike,
I recall that this work was mentioned during the last review in my series. However, I didn't have time to address it then because I was still working on the HVO refactoring. I really appreciate you taking this on. Thanks for your work.
I've reviewed Sashiko's comments as well, and it doesn't look like there are any major issues. Therefore, feel free to add my ack for this whole series in your v2 version with the proper fix.
Muchun,
Thanks
Quoted 39 lines
Quoted 35 lines
---
Mike Rapoport (Microsoft) (3):
mm: split outmm_initand memblock declarations frominternal.h
mm: split out sparse declarations frominternal.h
mm: split out vmalloc declarations frominternal.hMAINTAINERS | 3 + kernel/liveupdate/kexec_handover.c | 3 +- mm/cma.c | 1 + mm/execmem.c | 1 + mm/hugetlb.c | 1 + mm/internal.h | 183 ------------------------------------- mm/kmsan/hooks.c | 1 + mm/kmsan/shadow.c | 1 + mm/memblock.c | 1 + mm/memory_hotplug.c | 1 + mm/mm_init.c | 3 + mm/mm_init.h | 120 ++++++++++++++++++++++++ mm/page_alloc.c | 1 + mm/percpu-vm.c | 1 + mm/sparse-vmemmap.c | 2 + mm/sparse.c | 2 + mm/sparse.h | 63 +++++++++++++ mm/vmalloc.c | 1 + mm/vmalloc.h | 46 ++++++++++ 19 files changed, 251 insertions(+), 184 deletions(-)---
base-commit:820d5dfede0cd55dcbc89ce96fcfbb11b7c457ba
change-id: 20260707-internal-h-2efef660381d--
Sincerely yours,
Mike.Signature · 2 lines
Sincerely yours, Mike.
Uladzislau Rezki
maintainerQuoted 22 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.---
Mike Rapoport (Microsoft) (3):
mm: split outmm_initand memblock declarations frominternal.h
mm: split out sparse declarations frominternal.h
mm: split out vmalloc declarations frominternal.hMAINTAINERS | 3 + kernel/liveupdate/kexec_handover.c | 3 +- mm/cma.c | 1 + mm/execmem.c | 1 + mm/hugetlb.c | 1 + mm/internal.h | 183 ------------------------------------- mm/kmsan/hooks.c | 1 + mm/kmsan/shadow.c | 1 + mm/memblock.c | 1 + mm/memory_hotplug.c | 1 + mm/mm_init.c | 3 +
Quoted 9 lines
mm/mm_init.h | 120 ++++++++++++++++++++++++ mm/page_alloc.c | 1 + mm/percpu-vm.c | 1 + mm/sparse-vmemmap.c | 2 + mm/sparse.c | 2 + mm/sparse.h | 63 +++++++++++++ mm/vmalloc.c | 1 + mm/vmalloc.h | 46 ++++++++++
Thank you for splitting vmalloc. Later on we/i can move other things from main vmalloc.h into this local variant.
--
Uladzislau Rezki