* [PATCH v2 1/3] mm: split out mm_init and memblock declarations from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
@ 2026-07-09 10:00 ` Mike Rapoport (Microsoft)
2026-07-09 10:00 ` [PATCH v2 2/3] mm: split out sparse " Mike Rapoport (Microsoft)
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-07-09 10:00 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Lorenzo Stoakes, Marco Elver, Michal Hocko,
Mike Rapoport, Muchun Song, Oscar Salvador, Pasha Tatashin,
Pratyush Yadav, Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki,
Vlastimil Babka, Zi Yan, kasan-dev, kexec, linux-cxl,
linux-kernel, linux-mm
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.
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
---
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(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 2acd811d3746..33cef4d8e1ee 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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/
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 4834a809985a..fe11cbf1006e 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -35,6 +35,7 @@
* internal APIs.
*/
#include "../../mm/internal.h"
+#include "../../mm/mm_init.h"
#include "../kexec_internal.h"
#include "kexec_handover_internal.h"
diff --git a/mm/cma.c b/mm/cma.c
index 31073738f2ac..a7929c758df1 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -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;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a85ea663b192..f4a7bf6fb518 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -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;
diff --git a/mm/internal.h b/mm/internal.h
index 3d30650a8440..59adb140fc7a 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -716,9 +716,6 @@ void set_recommended_min_free_kbytes(void);
extern char * const zone_names[MAX_NR_ZONES];
-/* perform sanity checks on struct pages being allocated or freed */
-DECLARE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
-
extern int min_free_kbytes;
extern int defrag_mode;
@@ -726,19 +723,9 @@ void setup_per_zone_wmarks(void);
void calculate_min_free_kbytes(void);
int __meminit init_per_zone_wmark_min(void);
-void set_zone_contiguous(struct zone *zone);
-bool pfn_range_intersects_zones(int nid, unsigned long start_pfn,
- unsigned long nr_pages);
-
-static inline void clear_zone_contiguous(struct zone *zone)
-{
- zone->contiguous = false;
-}
-
extern int __isolate_free_page(struct page *page, unsigned int order);
extern void __putback_isolated_page(struct page *page, unsigned int order,
int mt);
-extern void memblock_free_pages(unsigned long pfn, unsigned int order);
/*
* This will have no effect, other than possibly generating a warning, if the
@@ -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);
-
/*
* mm/sparse.c
*/
@@ -948,9 +927,6 @@ int
isolate_migratepages_range(struct compact_control *cc,
unsigned long low_pfn, unsigned long end_pfn);
-/* Free whole pageblock and set its migration type to MIGRATE_CMA. */
-void init_cma_reserved_pageblock(struct page *page);
-
#endif /* CONFIG_COMPACTION || CONFIG_CMA */
struct cma;
@@ -958,7 +934,6 @@ struct cma;
#ifdef CONFIG_CMA
bool cma_validate_zones(struct cma *cma);
void *cma_reserve_early(struct cma *cma, unsigned long size);
-void init_cma_pageblock(struct page *page);
#else
static inline bool cma_validate_zones(struct cma *cma)
{
@@ -968,9 +943,6 @@ static inline void *cma_reserve_early(struct cma *cma, unsigned long size)
{
return NULL;
}
-static inline void init_cma_pageblock(struct page *page)
-{
-}
#endif
/* mm/util.c */
@@ -1177,63 +1149,6 @@ static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
}
#endif /* !CONFIG_MMU */
-/* Memory initialisation debug and verification */
-#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
-DECLARE_STATIC_KEY_TRUE(deferred_pages);
-
-static inline bool deferred_pages_enabled(void)
-{
- return static_branch_unlikely(&deferred_pages);
-}
-
-bool __init deferred_grow_zone(struct zone *zone, unsigned int order);
-#else
-static inline bool deferred_pages_enabled(void)
-{
- return false;
-}
-#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
-
-void init_deferred_page(unsigned long pfn, int nid);
-
-enum mminit_level {
- MMINIT_WARNING,
- MMINIT_VERIFY,
- MMINIT_TRACE
-};
-
-#ifdef CONFIG_DEBUG_MEMORY_INIT
-
-extern int mminit_loglevel;
-
-#define mminit_dprintk(level, prefix, fmt, arg...) \
-do { \
- if (level < mminit_loglevel) { \
- if (level <= MMINIT_WARNING) \
- pr_warn("mminit::" prefix " " fmt, ##arg); \
- else \
- printk(KERN_DEBUG "mminit::" prefix " " fmt, ##arg); \
- } \
-} while (0)
-
-extern void mminit_verify_pageflags_layout(void);
-extern void mminit_verify_zonelist(void);
-#else
-
-static inline void mminit_dprintk(enum mminit_level level,
- const char *prefix, const char *fmt, ...)
-{
-}
-
-static inline void mminit_verify_pageflags_layout(void)
-{
-}
-
-static inline void mminit_verify_zonelist(void)
-{
-}
-#endif /* CONFIG_DEBUG_MEMORY_INIT */
-
#define NODE_RECLAIM_NOSCAN -2
#define NODE_RECLAIM_FULL -1
#define NODE_RECLAIM_SOME 0
@@ -1532,9 +1447,6 @@ static inline bool gup_must_unshare(struct vm_area_struct *vma,
return !PageAnonExclusive(page);
}
-extern bool mirrored_kernelcore;
-bool memblock_has_mirror(void);
-void memblock_free_all(void);
static __always_inline void vma_set_range(struct vm_area_struct *vma,
unsigned long start, unsigned long end,
@@ -1573,9 +1485,6 @@ static inline bool pte_needs_soft_dirty_wp(struct vm_area_struct *vma, pte_t pte
return vma_soft_dirty_enabled(vma) && !pte_soft_dirty(pte);
}
-void __meminit __init_single_page(struct page *page, unsigned long pfn,
- unsigned long zone, int nid);
-
/* shrinker related functions */
unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg,
int priority);
diff --git a/mm/memblock.c b/mm/memblock.c
index 6349c48154f4..777c69f05400 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -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
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 11ab2f7bc7f3..99090f49d2df 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -40,6 +40,7 @@
#include <asm/tlbflush.h>
#include "internal.h"
+#include "mm_init.h"
#include "page_alloc.h"
#include "shuffle.h"
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 537664974ab1..39583c028e34 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -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"
diff --git a/mm/mm_init.h b/mm/mm_init.h
new file mode 100644
index 000000000000..39f75df9be1c
--- /dev/null
+++ b/mm/mm_init.h
@@ -0,0 +1,120 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * mm_init.h:
+ *
+ * mm/ internal mm_init and memblock declarations
+ */
+
+#ifndef __MM_MM_INIT_H
+#define __MM_MM_INIT_H
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/mmzone.h>
+#include <linux/jump_label.h>
+#include <linux/printk.h>
+
+struct page;
+struct vmem_altmap;
+
+/* perform sanity checks on struct pages being allocated or freed */
+DECLARE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
+
+void set_zone_contiguous(struct zone *zone);
+bool pfn_range_intersects_zones(int nid, unsigned long start_pfn,
+ unsigned long nr_pages);
+
+static inline void clear_zone_contiguous(struct zone *zone)
+{
+ zone->contiguous = false;
+}
+
+void memblock_free_pages(unsigned long pfn, unsigned int order);
+
+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);
+
+#if defined CONFIG_COMPACTION || defined CONFIG_CMA
+/* Free whole pageblock and set its migration type to MIGRATE_CMA. */
+void init_cma_reserved_pageblock(struct page *page);
+#endif
+
+#ifdef CONFIG_CMA
+void init_cma_pageblock(struct page *page);
+#else
+static inline void init_cma_pageblock(struct page *page)
+{
+}
+#endif
+
+/* Memory initialisation debug and verification */
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+DECLARE_STATIC_KEY_TRUE(deferred_pages);
+
+static inline bool deferred_pages_enabled(void)
+{
+ return static_branch_unlikely(&deferred_pages);
+}
+
+bool __init deferred_grow_zone(struct zone *zone, unsigned int order);
+#else
+static inline bool deferred_pages_enabled(void)
+{
+ return false;
+}
+#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
+
+void init_deferred_page(unsigned long pfn, int nid);
+
+enum mminit_level {
+ MMINIT_WARNING,
+ MMINIT_VERIFY,
+ MMINIT_TRACE
+};
+
+#ifdef CONFIG_DEBUG_MEMORY_INIT
+
+extern int mminit_loglevel;
+
+#define mminit_dprintk(level, prefix, fmt, arg...) \
+do { \
+ if (level < mminit_loglevel) { \
+ if (level <= MMINIT_WARNING) \
+ pr_warn("mminit::" prefix " " fmt, ##arg); \
+ else \
+ printk(KERN_DEBUG "mminit::" prefix " " fmt, ##arg); \
+ } \
+} while (0)
+
+void mminit_verify_pageflags_layout(void);
+void mminit_verify_zonelist(void);
+#else
+
+static inline void mminit_dprintk(enum mminit_level level,
+ const char *prefix, const char *fmt, ...)
+{
+}
+
+static inline void mminit_verify_pageflags_layout(void)
+{
+}
+
+static inline void mminit_verify_zonelist(void)
+{
+}
+#endif /* CONFIG_DEBUG_MEMORY_INIT */
+
+extern bool mirrored_kernelcore;
+bool memblock_has_mirror(void);
+void memblock_free_all(void);
+
+void __meminit __init_single_page(struct page *page, unsigned long pfn,
+ unsigned long zone, int nid);
+
+#endif /* __MM_MM_INIT_H */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 543cd2fc88d5..03bf4933ddb7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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"
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 515a404b66c0..10dd4a9b591b 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -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
diff --git a/mm/sparse.c b/mm/sparse.c
index b5c74aab3379..d54e30f58b93 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -15,6 +15,7 @@
#include <linux/swapops.h>
#include <linux/vmstat.h>
#include "internal.h"
+#include "mm_init.h"
#include <asm/dma.h>
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 2/3] mm: split out sparse declarations from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
2026-07-09 10:00 ` [PATCH v2 1/3] mm: split out mm_init and memblock declarations " Mike Rapoport (Microsoft)
@ 2026-07-09 10:00 ` Mike Rapoport (Microsoft)
2026-07-09 10:00 ` [PATCH v2 3/3] mm: split out vmalloc " Mike Rapoport (Microsoft)
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-07-09 10:00 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Lorenzo Stoakes, Marco Elver, Michal Hocko,
Mike Rapoport, Muchun Song, Oscar Salvador, Pasha Tatashin,
Pratyush Yadav, Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki,
Vlastimil Babka, Zi Yan, kasan-dev, kexec, linux-cxl,
linux-kernel, linux-mm
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.
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
---
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(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 33cef4d8e1ee..5c1aed067656 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
diff --git a/mm/internal.h b/mm/internal.h
index 59adb140fc7a..a29a7dab2e6c 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -807,58 +807,6 @@ static inline void init_compound_tail(struct page *tail,
prep_compound_tail(tail, head, order);
}
-/*
- * mm/sparse.c
- */
-#ifdef CONFIG_SPARSEMEM
-void sparse_init(void);
-int sparse_index_init(unsigned long section_nr, int nid);
-
-static inline void sparse_init_one_section(struct mem_section *ms,
- unsigned long pnum, struct page *mem_map,
- struct mem_section_usage *usage, unsigned long flags)
-{
- unsigned long coded_mem_map;
-
- BUILD_BUG_ON(SECTION_MAP_LAST_BIT > PFN_SECTION_SHIFT);
-
- /*
- * We encode the start PFN of the section into the mem_map such that
- * page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it
- * from the page pointer to obtain the PFN.
- */
- coded_mem_map = (unsigned long)(mem_map - section_nr_to_pfn(pnum));
- VM_WARN_ON_ONCE(coded_mem_map & ~SECTION_MAP_MASK);
-
- ms->section_mem_map &= ~SECTION_MAP_MASK;
- ms->section_mem_map |= coded_mem_map;
- ms->section_mem_map |= flags | SECTION_HAS_MEM_MAP;
- ms->usage = usage;
-}
-
-static inline void __section_mark_present(struct mem_section *ms,
- unsigned long section_nr)
-{
- if (section_nr > __highest_present_section_nr)
- __highest_present_section_nr = section_nr;
-
- ms->section_mem_map |= SECTION_MARKED_PRESENT;
-}
-#else
-static inline void sparse_init(void) {}
-#endif /* CONFIG_SPARSEMEM */
-
-/*
- * mm/sparse-vmemmap.c
- */
-#ifdef CONFIG_SPARSEMEM_VMEMMAP
-void sparse_init_subsection_map(void);
-#else
-static inline void sparse_init_subsection_map(void)
-{
-}
-#endif /* CONFIG_SPARSEMEM_VMEMMAP */
-
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
/*
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 39583c028e34..b557e5fe35f3 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -35,6 +35,7 @@
#include "internal.h"
#include "mm_init.h"
#include "page_alloc.h"
+#include "sparse.h"
#include "slab.h"
#include "shuffle.h"
diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 10dd4a9b591b..458b0b9570ff 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -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
diff --git a/mm/sparse.c b/mm/sparse.c
index d54e30f58b93..704a9dec2b9a 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -16,6 +16,7 @@
#include <linux/vmstat.h>
#include "internal.h"
#include "mm_init.h"
+#include "sparse.h"
#include <asm/dma.h>
/*
diff --git a/mm/sparse.h b/mm/sparse.h
new file mode 100644
index 000000000000..95aa031213f2
--- /dev/null
+++ b/mm/sparse.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * sparse.h:
+ *
+ * mm/ internal sparse and sparse-vmemmap declarations
+ */
+
+#ifndef __MM_SPARSE_H
+#define __MM_SPARSE_H
+
+#include <linux/mmzone.h>
+
+/*
+ * mm/sparse.c
+ */
+#ifdef CONFIG_SPARSEMEM
+void sparse_init(void);
+int sparse_index_init(unsigned long section_nr, int nid);
+
+static inline void sparse_init_one_section(struct mem_section *ms,
+ unsigned long pnum, struct page *mem_map,
+ struct mem_section_usage *usage, unsigned long flags)
+{
+ unsigned long coded_mem_map;
+
+ BUILD_BUG_ON(SECTION_MAP_LAST_BIT > PFN_SECTION_SHIFT);
+
+ /*
+ * We encode the start PFN of the section into the mem_map such that
+ * page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it
+ * from the page pointer to obtain the PFN.
+ */
+ coded_mem_map = (unsigned long)(mem_map - section_nr_to_pfn(pnum));
+ VM_WARN_ON_ONCE(coded_mem_map & ~SECTION_MAP_MASK);
+
+ ms->section_mem_map &= ~SECTION_MAP_MASK;
+ ms->section_mem_map |= coded_mem_map;
+ ms->section_mem_map |= flags | SECTION_HAS_MEM_MAP;
+ ms->usage = usage;
+}
+
+static inline void __section_mark_present(struct mem_section *ms,
+ unsigned long section_nr)
+{
+ if (section_nr > __highest_present_section_nr)
+ __highest_present_section_nr = section_nr;
+
+ ms->section_mem_map |= SECTION_MARKED_PRESENT;
+}
+#else
+static inline void sparse_init(void) {}
+#endif /* CONFIG_SPARSEMEM */
+
+/*
+ * mm/sparse-vmemmap.c
+ */
+#ifdef CONFIG_SPARSEMEM_VMEMMAP
+void sparse_init_subsection_map(void);
+#else
+static inline void sparse_init_subsection_map(void) {}
+#endif /* CONFIG_SPARSEMEM_VMEMMAP */
+
+#endif /* __MM_SPARSE_H */
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 3/3] mm: split out vmalloc declarations from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
2026-07-09 10:00 ` [PATCH v2 1/3] mm: split out mm_init and memblock declarations " Mike Rapoport (Microsoft)
2026-07-09 10:00 ` [PATCH v2 2/3] mm: split out sparse " Mike Rapoport (Microsoft)
@ 2026-07-09 10:00 ` Mike Rapoport (Microsoft)
2026-07-09 10:09 ` [PATCH v2 0/3] mm: split a couple of headers " Vlastimil Babka (SUSE)
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-07-09 10:00 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Lorenzo Stoakes, Marco Elver, Michal Hocko,
Mike Rapoport, Muchun Song, Oscar Salvador, Pasha Tatashin,
Pratyush Yadav, Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki,
Vlastimil Babka, Zi Yan, kasan-dev, kexec, linux-cxl,
linux-kernel, linux-mm
mm/internal.h becomes more and more bloated.
Move declarations related to vmalloc to a new mm/vmalloc.h header.
No functional changes.
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
---
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(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 5c1aed067656..9665f360bed8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index fe11cbf1006e..78ff267bf51e 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -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"
diff --git a/mm/execmem.c b/mm/execmem.c
index 084a207e4278..74a178a87e75 100644
--- a/mm/execmem.c
+++ b/mm/execmem.c
@@ -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;
diff --git a/mm/internal.h b/mm/internal.h
index a29a7dab2e6c..e5dcab69eb4f 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -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
*/
diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c
index 8f22d1f22981..5f1b8053f9fa 100644
--- a/mm/kmsan/hooks.c
+++ b/mm/kmsan/hooks.c
@@ -21,6 +21,7 @@
#include <linux/usb.h>
#include "../internal.h"
+#include "../vmalloc.h"
#include "../slab.h"
#include "kmsan.h"
diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
index 8fde939784a7..0c88d89bf0d6 100644
--- a/mm/kmsan/shadow.c
+++ b/mm/kmsan/shadow.c
@@ -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)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index b557e5fe35f3..711f821f7b3c 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -38,6 +38,7 @@
#include "sparse.h"
#include "slab.h"
#include "shuffle.h"
+#include "vmalloc.h"
#include <asm/setup.h>
diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
index 7ed216192fc0..509d8901835c 100644
--- a/mm/percpu-vm.c
+++ b/mm/percpu-vm.c
@@ -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)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1191cda3b4e8..4b0362cbdf5a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -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;
diff --git a/mm/vmalloc.h b/mm/vmalloc.h
new file mode 100644
index 000000000000..dcfe30eaa80c
--- /dev/null
+++ b/mm/vmalloc.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * mm-internal APIs for vmalloc
+ */
+#ifndef __MM_VMALLOC_H
+#define __MM_VMALLOC_H
+
+#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;
+}
+
+static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
+{
+}
+#endif
+
+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);
+
+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);
+
+#endif /* __MM_VMALLOC_H */
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/3] mm: split a couple of headers from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
` (2 preceding siblings ...)
2026-07-09 10:00 ` [PATCH v2 3/3] mm: split out vmalloc " Mike Rapoport (Microsoft)
@ 2026-07-09 10:09 ` Vlastimil Babka (SUSE)
2026-07-09 10:21 ` David Hildenbrand (Arm)
2026-07-09 12:59 ` Pratyush Yadav
2026-07-10 0:13 ` SJ Park
5 siblings, 1 reply; 9+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-09 10:09 UTC (permalink / raw)
To: Mike Rapoport (Microsoft), Andrew Morton, David Hildenbrand
Cc: Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Lorenzo Stoakes, Marco Elver, Michal Hocko,
Muchun Song, Oscar Salvador, Pasha Tatashin, Pratyush Yadav,
Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki, Zi Yan,
kasan-dev, kexec, linux-cxl, linux-kernel, linux-mm
On 7/9/26 12:00, Mike Rapoport (Microsoft) wrote:
> 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/20260709-internal-h-v1-0-956d5092782d@kernel.org
>
> ---
> 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(-)
Sounds good
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---
> base-commit: 59e34180e138a293260301c139cf7ee800978533
> change-id: 20260707-internal-h-2efef660381d
>
> --
> Sincerely yours,
> Mike.
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/3] mm: split a couple of headers from internal.h
2026-07-09 10:09 ` [PATCH v2 0/3] mm: split a couple of headers " Vlastimil Babka (SUSE)
@ 2026-07-09 10:21 ` David Hildenbrand (Arm)
2026-07-09 15:36 ` Lorenzo Stoakes
0 siblings, 1 reply; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-09 10:21 UTC (permalink / raw)
To: Vlastimil Babka (SUSE), Mike Rapoport (Microsoft), Andrew Morton
Cc: Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Lorenzo Stoakes, Marco Elver, Michal Hocko,
Muchun Song, Oscar Salvador, Pasha Tatashin, Pratyush Yadav,
Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki, Zi Yan,
kasan-dev, kexec, linux-cxl, linux-kernel, linux-mm
On 7/9/26 12:09, Vlastimil Babka (SUSE) wrote:
> On 7/9/26 12:00, Mike Rapoport (Microsoft) wrote:
>> 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/20260709-internal-h-v1-0-956d5092782d@kernel.org
>>
>> ---
>> 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(-)
>
> Sounds good
>
> Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Agreed
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] mm: split a couple of headers from internal.h
2026-07-09 10:21 ` David Hildenbrand (Arm)
@ 2026-07-09 15:36 ` Lorenzo Stoakes
0 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes @ 2026-07-09 15:36 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Vlastimil Babka (SUSE), Mike Rapoport (Microsoft), Andrew Morton,
Alexander Graf, Alexander Potapenko, Brendan Jackman,
Christoph Lameter, Dennis Zhou, Dmitry Vyukov, Johannes Weiner,
Liam R. Howlett, Marco Elver, Michal Hocko, Muchun Song,
Oscar Salvador, Pasha Tatashin, Pratyush Yadav,
Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki, Zi Yan,
kasan-dev, kexec, linux-cxl, linux-kernel, linux-mm
On Thu, Jul 09, 2026 at 12:21:12PM +0200, David Hildenbrand (Arm) wrote:
> On 7/9/26 12:09, Vlastimil Babka (SUSE) wrote:
> > On 7/9/26 12:00, Mike Rapoport (Microsoft) wrote:
> >> 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/20260709-internal-h-v1-0-956d5092782d@kernel.org
> >>
> >> ---
> >> 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 ++++++++++
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.
> >> 19 files changed, 251 insertions(+), 184 deletions(-)
> >
> > Sounds good
> >
> > Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
>
> Agreed
>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Oh hey me too! <3
Acked-by: Lorenzo Stoakes <ljs@kernel.org>
>
> --
> Cheers,
>
> David
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] mm: split a couple of headers from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
` (3 preceding siblings ...)
2026-07-09 10:09 ` [PATCH v2 0/3] mm: split a couple of headers " Vlastimil Babka (SUSE)
@ 2026-07-09 12:59 ` Pratyush Yadav
2026-07-10 0:13 ` SJ Park
5 siblings, 0 replies; 9+ messages in thread
From: Pratyush Yadav @ 2026-07-09 12:59 UTC (permalink / raw)
To: Mike Rapoport (Microsoft)
Cc: Andrew Morton, David Hildenbrand, Alexander Graf,
Alexander Potapenko, Brendan Jackman, Christoph Lameter,
Dennis Zhou, Dmitry Vyukov, Johannes Weiner, Liam R. Howlett,
Lorenzo Stoakes, Marco Elver, Michal Hocko, Muchun Song,
Oscar Salvador, Pasha Tatashin, Pratyush Yadav,
Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki, Vlastimil Babka,
Zi Yan, kasan-dev, kexec, linux-cxl, linux-kernel, linux-mm
On Thu, Jul 09 2026, Mike Rapoport (Microsoft) wrote:
> mm/internal.h becomes more and more bloated.
>
> Split declarations related to mm_init, memblock, vmalloc and sparse into
> new headers.
Acked-by: Pratyush Yadav <pratyush@kernel.org>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/3] mm: split a couple of headers from internal.h
2026-07-09 10:00 [PATCH v2 0/3] mm: split a couple of headers from internal.h Mike Rapoport (Microsoft)
` (4 preceding siblings ...)
2026-07-09 12:59 ` Pratyush Yadav
@ 2026-07-10 0:13 ` SJ Park
5 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-07-10 0:13 UTC (permalink / raw)
To: Mike Rapoport (Microsoft)
Cc: SJ Park, Andrew Morton, David Hildenbrand, Alexander Graf,
Alexander Potapenko, Brendan Jackman, Christoph Lameter,
Dennis Zhou, Dmitry Vyukov, Johannes Weiner, Liam R. Howlett,
Lorenzo Stoakes, Marco Elver, Michal Hocko, Muchun Song,
Oscar Salvador, Pasha Tatashin, Pratyush Yadav,
Suren Baghdasaryan, Tejun Heo, Uladzislau Rezki, Vlastimil Babka,
Zi Yan, kasan-dev, kexec, linux-cxl, linux-kernel, linux-mm
On Thu, 09 Jul 2026 13:00:02 +0300 "Mike Rapoport (Microsoft)" <rppt@kernel.org> wrote:
> mm/internal.h becomes 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,
Acked-by: SJ Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 9+ messages in thread