mm: split a couple of headers from internal.h
Subsystems (13)
Mike Rapoport (Microsoft)
maintainerv2 cover 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.
---
v2 changes:
* fix fallouts of rebase fixups of checkpatch warnings
v1: https://patch.msgid.link/[email protected]
---
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: 59e34180e138a293260301c139cf7ee800978533
change-id: 20260707-internal-h-2efef660381d
--
Sincerely yours,
Mike.
Mike Rapoport (Microsoft)
maintainerPATCH v2 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 + mm/sparse.c | 1 + 12 files changed, 130 insertions(+), 91 deletions(-)
MAINTAINERS +1 -0
@@ -16880,6 +16880,7 @@ F: include/linux/memblock.h 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
mm/sparse.c +1 -0
@@ -15,6 +15,7 @@#include <linux/swapops.h> #include <linux/vmstat.h> #include "internal.h" +#include "mm_init.h" #include <asm/dma.h> /*
Signature · 1 line
2.53.0
Mike Rapoport
maintainerRe: [PATCH v2 1/3] mm: split out mm_init and memblock declarations from internal.h
Quoted 9 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Move declarations for related to
mm/mm_init.candmm/memblock.cto a newmm/mm_init.hheader.No functional changes.
Signed-off-by Mike Rapoport (Microsoft) <[email protected]>Acked-by Muchun Song <[email protected]>
Quoted 14 lines
--- 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 + mm/sparse.c | 1 + 12 files changed, 130 insertions(+), 91 deletions(-)
As always I forgot to update the memblock tests :(
Andrew, can you please merge this as a fixup:
From 4724f0868aa5ab6bc1c054d0be1cca2067533c22 Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (Microsoft)" <[email protected]>
Date: Sat, 11 Jul 2026 18:11:13 +0300
Subject: [PATCH] memblock tests: split stubfs from internal.h to mm_init.h
Following the split of declarations from mm/internal.h to mm/mm_init.h update memblock tests to match the kernel core, otherwise they fail to build.
--- tools/testing/memblock/internal.h | 20 -------------------- tools/testing/memblock/mm_init.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 tools/testing/memblock/mm_init.h
tools/testing/memblock/internal.h +0 -20
@@ -28,22 +28,6 @@ static inline struct page *virt_to_page(void *virt)return virt; } -void memblock_free_pages (unsigned long pfn,unsigned int order) -{ -} - -static inline void accept_memory (phys_addr_t start,unsigned long size) -{ -} - -unsigned long free_reserved_area (void *start,void *end,int poison,const char *s); -void free_reserved_page (struct page *page); - -static inline bool deferred_pages_enabled (void ) -{ -return false; -} -#define for_each_valid_pfn (pfn, start_pfn, end_pfn) \ for ((pfn) = (start_pfn); (pfn) < (end_pfn); (pfn)++)
@@ -60,10 +44,6 @@ static inline bool __is_kernel(unsigned long addr)#define for_each_valid_pfn (pfn, start_pfn, end_pfn) \ for ((pfn) = (start_pfn); (pfn) < (end_pfn); (pfn)++) -static inline void init_deferred_page (unsigned long pfn,int nid) -{ -} -#define __SetPageReserved (p) ((void)(p))#endif
tools/testing/memblock/mm_init.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __MM_MM_INIT_H +#define __MM_MM_INIT_H + +void memblock_free_pages (unsigned long pfn,unsigned int order) +{ +} + +static inline void accept_memory (phys_addr_t start,unsigned long size) +{ +} + +unsigned long free_reserved_area (void *start,void *end,int poison,const char *s); +void free_reserved_page (struct page *page); + +static inline bool deferred_pages_enabled (void ) +{ +return false; +} + +static inline void init_deferred_page (unsigned long pfn,int nid) +{ +} +#endif /* __MM_MM_INIT_H */
Signature · 6 lines
2.53.0 -- Sincerely yours, Mike.
Mike Rapoport (Microsoft)
maintainerPATCH v2 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 | 1 + mm/sparse.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 67 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 +1 -0
@@ -16,6 +16,7 @@#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 v2 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
@@ -28815,6 +28815,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
Quoted 29 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.---
v2 changes:
* fix fallouts of rebase fixups of checkpatch warningsv1: https://patch.msgid.link/[email protected]
---
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 ++++++++++++++++++++++++
Quoted 8 lines
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(-)
Sounds good
Quoted 8 lines
---
base-commit:59e34180e138a293260301c139cf7ee800978533
change-id: 20260707-internal-h-2efef660381d--
Sincerely yours,
Mike.
Quoted 39 lines · Vlastimil Babka (SUSE)
Quoted 29 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.---
v2 changes:
* fix fallouts of rebase fixups of checkpatch warningsv1: https://patch.msgid.link/[email protected]
---
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 ++++++++++++++++++++++++Quoted 8 lines
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(-)
Quoted 3 lines
Sounds good
Agreed
Signature · 3 lines
Cheers, David
Quoted 30 lines · David Hildenbrand (Arm)
Quoted 29 lines · Vlastimil Babka (SUSE)
Quoted 28 lines · Mike Rapoport (Microsoft)
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.---
v2 changes:
* fix fallouts of rebase fixups of checkpatch warningsv1: https://patch.msgid.link/[email protected]
---
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 8 lines
Quoted 8 lines
Quoted 8 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 ++++++++++
One thing to be wary of, and I mean I'm going to get a bunch of conflicts with my mega series, but anythign that uses vma's should use internal.h rather than vma.h directly (the mega series touches this).
But nothing you changed does use VMAs afaict so should be good.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
19 files changed, 251 insertions(+), 184 deletions(-)Sounds good
Agreed
Oh hey me too! <3
Quoted 5 lines
--
Cheers,David
Cheers, Lorenzo
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.
[...]
Signature · 2 lines
Regards, Pratyush Yadav
Quoted 4 lines · On Thu, 09 Jul 2026 13:00:02 +0300 "Mike Rapoport (Microsoft)"…
mm/internal.hbecomes more and more bloated.Split declarations related to
mm_init, memblock, vmalloc and sparse into new headers.
Nice. I also confirmed I can successfully build mm/ for my main test setup after applying this series.
For the series,
Thanks,
SJ
[...]