[PATCH 27/49] mm: call memblocks_present() before HugeTLB initialization
Muchun Song
songmuchun at bytedance.com
Sun Apr 5 22:52:18 AEST 2026
Extract memblocks_present() from sparse_init() and call it earlier in
mm_core_init_early().
This ensures that the struct mem_section array is properly allocated
and marked as present before HugeTLB bootmem allocation. This is a
necessary preparation for the subsequent patches, which will need to
perform early setting of the section order for HugeTLB pages.
Signed-off-by: Muchun Song <songmuchun at bytedance.com>
---
mm/internal.h | 2 ++
mm/mm_init.c | 1 +
mm/sparse.c | 4 +---
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index c0d0f546864c..27c06250d6b8 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -963,6 +963,7 @@ void memmap_init_range(unsigned long, int, unsigned long, unsigned long,
* mm/sparse.c
*/
#ifdef CONFIG_SPARSEMEM
+void memblocks_present(void);
void sparse_init(void);
int sparse_index_init(unsigned long section_nr, int nid);
@@ -1000,6 +1001,7 @@ static inline void __section_mark_present(struct mem_section *ms,
int section_vmemmap_pages(unsigned long pfn, unsigned long nr_pages,
struct vmem_altmap *altmap, struct dev_pagemap *pgmap);
#else
+static inline void memblocks_present(void) {}
static inline void sparse_init(void) {}
#endif /* CONFIG_SPARSEMEM */
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 7f5b326e9298..b47f65425bc1 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2675,6 +2675,7 @@ void __init __weak mem_init(void)
void __init mm_core_init_early(void)
{
+ memblocks_present();
free_area_init();
/* Zone data structures are available from here. */
hugetlb_cma_reserve();
diff --git a/mm/sparse.c b/mm/sparse.c
index 62659752980e..7779554c5a0c 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -195,7 +195,7 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en
* This is a convenience function that is useful to mark all of the systems
* memory as present during initialization.
*/
-static void __init memblocks_present(void)
+void __init memblocks_present(void)
{
unsigned long start, end;
int i, nid;
@@ -420,8 +420,6 @@ void __init sparse_init(void)
unsigned long pnum_end, pnum_begin, map_count = 1;
int nid_begin;
- memblocks_present();
-
if (compound_info_has_mask()) {
VM_WARN_ON_ONCE(!IS_ALIGNED((unsigned long) pfn_to_page(0),
MAX_FOLIO_VMEMMAP_ALIGN));
--
2.20.1
More information about the Linuxppc-dev
mailing list