arch, mm: consolidate hugetlb early reservation
Subsystems (33)
Mike Rapoport
maintainerv2 cover arch, mm: consolidate hugetlb early reservation
From: "Mike Rapoport (Microsoft)" <[email protected]>
Hi,
Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters.
Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap.
When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not.
To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations.
This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do.
These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*.
Patch 24 is a simple cleanup for MIPS.
Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups.
I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back.
The changes also available in git:
https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v2
v2 changes:
* move the hugetlb and memory map initializaion to mm_core_init_early()
* add Acks
v1: https://lore.kernel.org/all/[email protected]
Mike Rapoport (Microsoft) (28):
alpha: introduce arch_zone_limits_init()
arc: introduce arch_zone_limits_init()
arm: introduce arch_zone_limits_init()
arm64: introduce arch_zone_limits_init()
csky: introduce arch_zone_limits_init()
hexagon: introduce arch_zone_limits_init()
loongarch: introduce arch_zone_limits_init()
m68k: introduce arch_zone_limits_init()
microblaze: introduce arch_zone_limits_init()
mips: introduce arch_zone_limits_init()
nios2: introduce arch_zone_limits_init()
openrisc: introduce arch_zone_limits_init()
parisc: introduce arch_zone_limits_init()
powerpc: introduce arch_zone_limits_init()
riscv: introduce arch_zone_limits_init()
s390: introduce arch_zone_limits_init()
sh: introduce arch_zone_limits_init()
sparc: introduce arch_zone_limits_init()
um: introduce arch_zone_limits_init()
x86: introduce arch_zone_limits_init()
xtensa: introduce arch_zone_limits_init()
arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model
mips: drop paging_init()
x86: don't reserve hugetlb memory in setup_arch()
mm, arch: consolidate hugetlb CMA reservation
mm/hugetlb: drop hugetlb_cma_check()
Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc"
.../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/mm/init.c | 25 ++---------- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 61 files changed, 219 insertions(+), 394 deletions(-)
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 1/28 alpha: introduce arch_zone_limits_init()
From: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/alpha/mm/init.c | 15 ++++++++++----- include/linux/mm.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-)
arch/alpha/mm/init.c +10 -5
@@ -208,12 +208,8 @@ callback_init(void * kernel_end)return kernel_end; } -/* -* paging_init() sets up the memory map. -*/ -void __init paging_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfn) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };unsigned long dma_pfn; dma_pfn =virt_to_phys ((char *)MAX_DMA_ADDRESS ) >>PAGE_SHIFT ;
@@ -221,8 +217,17 @@ void __init paging_init(void) max_zone_pfn[ZONE_DMA ] = dma_pfn; max_zone_pfn[ZONE_NORMAL ] = max_pfn; +} + +/* +* paging_init() sets up the memory map. +*/ +void __init paging_init (void ) +{ +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };/* Initialize mem_map[]. */ +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn);/* Initialize the kernel's ZERO_PGE. */
include/linux/mm.h +1 -0
@@ -3552,6 +3552,7 @@ static inline unsigned long get_num_physpages(void)* free_area_init(max_zone_pfns); */ void free_area_init (unsigned long *max_zone_pfn); +void arch_zone_limits_init (unsigned long *max_zone_pfn);unsigned long node_map_pfn_alignment (void );extern unsigned long absent_pages_in_range (unsigned long start_pfn,unsigned long end_pfn);
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 2/28 arc: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/arc/mm/init.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
arch/arc/mm/init.c +20 -14
@@ -75,6 +75,25 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) base, TO_MB(size), !in_use ? "Not used":""); } +void __init arch_zone_limits_init (unsigned long *max_zone_pfn) +{ +/*----------------- node/zones setup --------------------------*/ + max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; + +#ifdef CONFIG_HIGHMEM +/* +* max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE. +* For HIGHMEM without PAE max_high_pfn should be less than +* min_low_pfn to guarantee that these two regions don't overlap. +* For PAE case highmem is greater than lowmem, so it is natural +* to use max_high_pfn. +* +* In both cases, holes should be handled by pfn_valid(). +*/ + max_zone_pfn[ZONE_HIGHMEM ] = max_high_pfn; +#endif +} +/* * First memory setup routine called from setup_arch() * 1. setup swapper's mm @init_mm
@@ -122,9 +141,6 @@ void __init setup_arch_memory(void)memblock_dump_all (); -/*----------------- node/zones setup --------------------------*/ - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; -#ifdef CONFIG_HIGHMEM /* * On ARC (w/o PAE) HIGHMEM addresses are actually smaller (0 based)
@@ -139,21 +155,11 @@ void __init setup_arch_memory(void) min_high_pfn =PFN_DOWN (high_mem_start); max_high_pfn =PFN_DOWN (high_mem_start + high_mem_sz); -/* -* max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE. -* For HIGHMEM without PAE max_high_pfn should be less than -* min_low_pfn to guarantee that these two regions don't overlap. -* For PAE case highmem is greater than lowmem, so it is natural -* to use max_high_pfn. -* -* In both cases, holes should be handled by pfn_valid(). -*/ - max_zone_pfn[ZONE_HIGHMEM ] = max_high_pfn; - arch_pfn_offset =min (min_low_pfn, min_high_pfn);kmap_init ();#endif /* CONFIG_HIGHMEM */ +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 3/28 arm: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/arm/mm/init.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
arch/arm/mm/init.c +12 -7
@@ -107,18 +107,23 @@ void __init setup_dma_zone(const struct machine_desc *mdesc)#endif } -static void __init zone_sizes_init (unsigned long min,unsigned long max_low, -unsigned long max_high) +void __init arch_zone_limits_init (unsigned long *max_zone_pfn) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -#ifdef CONFIG_ZONE_DMA - max_zone_pfn[ZONE_DMA ] =min (arm_dma_pfn_limit, max_low); + max_zone_pfn[ZONE_DMA ] =min (arm_dma_pfn_limit, max_low_pfn);#endif - max_zone_pfn[ZONE_NORMAL ] = max_low; + max_zone_pfn[ZONE_NORMAL ] = max_low_pfn;#ifdef CONFIG_HIGHMEM - max_zone_pfn[ZONE_HIGHMEM ] = max_high; + max_zone_pfn[ZONE_HIGHMEM ] = max_pfn;#endif +} + +static void __init zone_sizes_init (unsigned long min,unsigned long max_low, +unsigned long max_high) +{ +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; + +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 4/28 arm64: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
While on it rename zone_sizes_init() to dma_limits_init() to better reflect what that function does.
--- arch/arm64/mm/init.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
arch/arm64/mm/init.c +17 -5
@@ -118,7 +118,21 @@ static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)return min (zone_limit,memblock_end_of_DRAM () -1 ) +1 ; } -static void __init zone_sizes_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +phys_addr_t __maybe_unused dma32_phys_limit = +max_zone_phys (DMA_BIT_MASK (32 )); + +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA ] =PFN_DOWN (max_zone_phys (zone_dma_limit)); +#endif +#ifdef CONFIG_ZONE_DMA32 + max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (dma32_phys_limit); +#endif + max_zone_pfns[ZONE_NORMAL ] = max_pfn; +} + +static void __init dma_limits_init (void ) {unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 };phys_addr_t __maybe_unused acpi_zone_dma_limit;
@@ -139,17 +153,15 @@ static void __init zone_sizes_init(void)if (memblock_start_of_DRAM () <U32_MAX ) zone_dma_limit =min (zone_dma_limit,U32_MAX ); arm64_dma_phys_limit =max_zone_phys (zone_dma_limit); - max_zone_pfns[ZONE_DMA ] =PFN_DOWN (arm64_dma_phys_limit);#endif #ifdef CONFIG_ZONE_DMA32 - max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (dma32_phys_limit);if (!arm64_dma_phys_limit) arm64_dma_phys_limit = dma32_phys_limit;#endif if (!arm64_dma_phys_limit) arm64_dma_phys_limit =PHYS_MASK +1 ; - max_zone_pfns[ZONE_NORMAL ] = max_pfn; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
@@ -319,7 +331,7 @@ void __init bootmem_init(void)* done after the fixed reservations */ sparse_init (); -zone_sizes_init (); +dma_limits_init ();/* * Reserve the CMA area after arm64_dma_phys_limit was initialised.
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 5/28 csky: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/csky/kernel/setup.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/csky/kernel/setup.c +9 -3
@@ -51,6 +51,14 @@ static void __init setup_initrd(void) }#endif +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; +#endif +} +static void __init csky_memblock_init (void ) {unsigned long lowmem_size =PFN_DOWN (LOWMEM_LIMIT -PHYS_OFFSET_OFFSET );
@@ -83,12 +91,9 @@ static void __init csky_memblock_init(void)setup_initrd ();#endif - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; -mmu_init (min_low_pfn, max_low_pfn);#ifdef CONFIG_HIGHMEM - max_zone_pfn[ZONE_HIGHMEM ] = max_pfn; highstart_pfn = max_low_pfn; highend_pfn = max_pfn;
@@ -97,6 +102,7 @@ static void __init csky_memblock_init(void)dma_contiguous_reserve (0 ); +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 6/28 hexagon: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/hexagon/mm/init.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
arch/hexagon/mm/init.c +13 -10
@@ -54,6 +54,18 @@ void sync_icache_dcache(pte_t pte)__vmcache_idsync (addr,PAGE_SIZE ); } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +/* +* This is not particularly well documented anywhere, but +* give ZONE_NORMAL all the memory, including the big holes +* left by the kernel+bootmem_map which are already left as reserved +* in the bootmem_map; free_area_init should see those bits and +* adjust accordingly. +*/ + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +/* * In order to set up page allocator "nodes", * somebody has to call free_area_init() for UMA.
@@ -65,16 +77,7 @@ static void __init paging_init(void) {unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; -/* -* This is not particularly well documented anywhere, but -* give ZONE_NORMAL all the memory, including the big holes -* left by the kernel+bootmem_map which are already left as reserved -* in the bootmem_map; free_area_init should see those bits and -* adjust accordingly. -*/ - - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; - +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn);/* sets up the zonelists and mem_map */ /*
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 7/28 loongarch: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/loongarch/mm/init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/loongarch/mm/init.c +7 -3
@@ -60,15 +60,19 @@ int __ref page_is_ram(unsigned long pfn)return memblock_is_memory (addr) && !memblock_is_reserved (addr); } -void __init paging_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; -#ifdef CONFIG_ZONE_DMA32 max_zone_pfns[ZONE_DMA32 ] =MAX_DMA32_PFN ;#endif max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} + +void __init paging_init (void ) +{ +unsigned long max_zone_pfns[MAX_NR_ZONES ]; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 8/28 m68k: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
Since all variants of m68k add all memory to ZONE_DMA, it is possible to use unified implementation for arch_zone_limits_init() that sets the end of ZONE_DMA to memblock_end_of_DRAM().
--- arch/m68k/mm/init.c | 7 ++++++- arch/m68k/mm/mcfmmu.c | 2 +- arch/m68k/mm/motorola.c | 2 +- arch/m68k/mm/sun3mmu.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-)
arch/m68k/mm/init.c +6 -1
@@ -40,6 +40,11 @@void *empty_zero_page;EXPORT_SYMBOL (empty_zero_page); +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA ] =PFN_DOWN (memblock_end_of_DRAM ()); +} +#ifdef CONFIG_MMU int m68k_virt_to_node_shift;
@@ -69,7 +74,7 @@ void __init paging_init(void) high_memory = (void *) end_mem; empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); - max_zone_pfn[ZONE_DMA ] = end_mem >>PAGE_SHIFT ; +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
arch/m68k/mm/mcfmmu.c +1 -1
@@ -73,7 +73,7 @@ void __init paging_init(void) } current->mm =NULL ; - max_zone_pfn[ZONE_DMA ] =PFN_DOWN (_ramend); +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
arch/m68k/mm/motorola.c +1 -1
@@ -517,6 +517,6 @@ void __init paging_init(void)if (node_present_pages (i))node_set_state (i,N_NORMAL_MEMORY ); - max_zone_pfn[ZONE_DMA ] =memblock_end_of_DRAM (); +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
arch/m68k/mm/sun3mmu.c +1 -1
@@ -82,7 +82,7 @@ void __init paging_init(void) current->mm =NULL ;/* memory sizing is a hack stolen from motorola.c.. hope it works for us */ - max_zone_pfn[ZONE_DMA ] = ((unsigned long )high_memory) >>PAGE_SHIFT ; +arch_zone_limits_init (max_zone_pfn);/* I really wish I knew why the following change made things better... -- Sam */ free_area_init (max_zone_pfn);
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 9/28 microblaze: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/microblaze/mm/init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/microblaze/mm/init.c +11 -6
@@ -54,6 +54,16 @@ static void __init highmem_init(void) }#endif /* CONFIG_HIGHMEM */ +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_DMA ] = max_low_pfn; + max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; +#else + max_zone_pfns[ZONE_DMA ] = max_pfn; +#endif +} +/* * paging_init() sets up the page tables - in fact we've already done this. */
@@ -71,13 +81,8 @@ static void __init paging_init(void)#ifdef CONFIG_HIGHMEM highmem_init (); - - zones_size[ZONE_DMA ] = max_low_pfn; - zones_size[ZONE_HIGHMEM ] = max_pfn; -#else - zones_size[ZONE_DMA ] = max_pfn;#endif - +arch_zone_limits_init (zones_size);/* We don't have holes in memory map */ free_area_init (zones_size); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 10/28 mips: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/mips/loongson64/numa.c | 9 +++++++-- arch/mips/mm/init.c | 14 +++++++++----- arch/mips/sgi-ip27/ip27-memory.c | 7 ++++++- 3 files changed, 22 insertions(+), 8 deletions(-)
arch/mips/loongson64/numa.c +7 -2
@@ -154,13 +154,18 @@ static __init void prom_meminit(void) } } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA32 ] =MAX_DMA32_PFN ; + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +void __init paging_init (void ) {unsigned long zones_size[MAX_NR_ZONES ] = {0 , };pagetable_init (); - zones_size[ZONE_DMA32 ] =MAX_DMA32_PFN ; - zones_size[ZONE_NORMAL ] = max_low_pfn; +arch_zone_limits_init (zones_size);free_area_init (zones_size); }
arch/mips/mm/init.c +9 -5
@@ -394,12 +394,8 @@ void maar_init(void) }#ifndef CONFIG_NUMA -void __init paging_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -pagetable_init (); -#ifdef CONFIG_ZONE_DMA max_zone_pfns[ZONE_DMA ] =MAX_DMA_PFN ;#endif
@@ -417,7 +413,15 @@ void __init paging_init(void) max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn; }#endif +} + +void __init paging_init (void ) +{ +unsigned long max_zone_pfns[MAX_NR_ZONES ]; + +pagetable_init (); +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
arch/mips/sgi-ip27/ip27-memory.c +6 -1
@@ -406,11 +406,16 @@ void __init prom_meminit(void) } } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +void __init paging_init (void ) {unsigned long zones_size[MAX_NR_ZONES ] = {0 , };pagetable_init (); - zones_size[ZONE_NORMAL ] = max_low_pfn; +arch_zone_limits_init (zones_size);free_area_init (zones_size); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 11/28 nios2: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/nios2/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/nios2/mm/init.c +6 -2
@@ -38,6 +38,11 @@pgd_t *pgd_current; +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +/* * paging_init() continues the virtual memory environment setup which * was begun by the code in arch/head.S.
@@ -51,8 +56,7 @@ void __init paging_init(void)pagetable_init (); pgd_current = swapper_pg_dir; - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; - +arch_zone_limits_init (max_zone_pfn);/* pass the memory from the bootmem allocator to the main allocator */ free_area_init (max_zone_pfn);
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 12/28 openrisc: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/openrisc/mm/init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/openrisc/mm/init.c +8 -4
@@ -39,15 +39,19 @@int mem_init_done; -static void __init zone_sizes_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -/* * We use only ZONE_NORMAL */ - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} + +static void __init zone_sizes_init (void ) +{ +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 13/28 parisc: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/parisc/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/parisc/mm/init.c +6 -2
@@ -693,12 +693,16 @@ static void __init fixmap_init(void) }while (addr < end); } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] =PFN_DOWN (memblock_end_of_DRAM ()); +} +static void __init parisc_bootmem_free (void ) {unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - max_zone_pfn[0 ] =memblock_end_of_DRAM (); - +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 14/28 powerpc: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/powerpc/mm/mem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/powerpc/mm/mem.c +12 -10
@@ -221,13 +221,23 @@ static int __init mark_nonram_nosave(void)* anyway) will take a first dip into ZONE_NORMAL and get otherwise served by * ZONE_DMA. */ -static unsigned long max_zone_pfns[MAX_NR_ZONES ]; +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA ] =min (zone_dma_limit, max_low_pfn -1 ) +1 ; +#endif + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; +#endif +}/* * paging_init() sets up the page tables - in fact we've already done this. */ void __init paging_init (void ) { +unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long long total_ram =memblock_phys_mem_size ();phys_addr_t top_of_ram =memblock_end_of_DRAM ();int zone_dma_bits;
@@ -259,15 +269,7 @@ void __init paging_init(void) zone_dma_limit =DMA_BIT_MASK (zone_dma_bits); -#ifdef CONFIG_ZONE_DMA - max_zone_pfns[ZONE_DMA ] =min (max_low_pfn, -1UL << (zone_dma_bits -PAGE_SHIFT )); -#endif - max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; -#ifdef CONFIG_HIGHMEM - max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; -#endif - +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns);mark_nonram_nosave ();
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 15/28 riscv: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/riscv/mm/init.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/riscv/mm/init.c +7 -3
@@ -79,15 +79,19 @@ uintptr_t _dtb_early_pa __initdata;phys_addr_t dma32_phys_limit__initdata ; -static void __init zone_sizes_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 , }; -#ifdef CONFIG_ZONE_DMA32 max_zone_pfns[ZONE_DMA32 ] =PFN_DOWN (dma32_phys_limit);#endif max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} + +static void __init zone_sizes_init (void ) +{ +unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 , }; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 16/28 s390: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/s390/mm/init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/s390/mm/init.c +7 -2
@@ -86,6 +86,12 @@ static void __init setup_zero_pages(void) zero_page_mask = ((PAGE_SIZE << order) -1 ) &PAGE_MASK ; } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA ] =virt_to_pfn (MAX_DMA_ADDRESS ); + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +/* * paging_init() sets up the page tables */
@@ -97,8 +103,7 @@ void __init paging_init(void)sparse_init (); zone_dma_limit =DMA_BIT_MASK (31 );memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - max_zone_pfns[ZONE_DMA ] =virt_to_pfn (MAX_DMA_ADDRESS ); - max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 17/28 sh: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/sh/mm/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/sh/mm/init.c +6 -1
@@ -264,6 +264,11 @@ static void __init early_reserve_mem(void)reserve_crashkernel (); } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} +void __init paging_init (void ) {unsigned long max_zone_pfns[MAX_NR_ZONES ];
@@ -322,7 +327,7 @@ void __init paging_init(void)kmap_coherent_init ();memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 18/28 sparc: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/sparc/mm/init_64.c | 6 ++++++ arch/sparc/mm/srmmu.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
arch/sparc/mm/init_64.c +6 -0
@@ -2279,6 +2279,11 @@ static void __init reduce_memory(phys_addr_t limit_ram)memblock_enforce_memory_limit (limit_ram); } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = last_valid_pfn; +} +void __init paging_init (void ) {unsigned long end_pfn, shift, phys_base;
@@ -2461,6 +2466,7 @@ void __init paging_init(void) max_zone_pfns[ZONE_NORMAL ] = end_pfn; +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
arch/sparc/mm/srmmu.c +8 -4
@@ -884,6 +884,13 @@ static void __init map_kernel(void)void (*poke_srmmu)(void ) =NULL ; +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_DMA ] = max_low_pfn; + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; + max_zone_pfns[ZONE_HIGHMEM ] = highend_pfn; +} +void __init srmmu_paging_init (void ) {int i;
@@ -967,10 +974,7 @@ void __init srmmu_paging_init(void) {unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - max_zone_pfn[ZONE_DMA ] = max_low_pfn; - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn; - max_zone_pfn[ZONE_HIGHMEM ] = highend_pfn; - +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); } }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 19/28 um: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/um/kernel/mem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/um/kernel/mem.c +6 -1
@@ -84,6 +84,11 @@ void __init mem_init(void) kmalloc_ok =1 ; } +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ + max_zone_pfns[ZONE_NORMAL ] = high_physmem >>PAGE_SHIFT ; +} +void __init paging_init (void ) {unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };
@@ -94,7 +99,7 @@ void __init paging_init(void)panic ("%s: Failed to allocate %lu bytes align=%lx\n" , __func__,PAGE_SIZE ,PAGE_SIZE ); - max_zone_pfn[ZONE_NORMAL ] = high_physmem >>PAGE_SHIFT ; +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 20/28 x86: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/x86/mm/init.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/mm/init.c +9 -5
@@ -997,12 +997,8 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) }#endif -void __init zone_sizes_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); -#ifdef CONFIG_ZONE_DMA max_zone_pfns[ZONE_DMA ] =min (MAX_DMA_PFN , max_low_pfn);#endif
@@ -1013,7 +1009,15 @@ void __init zone_sizes_init(void)#ifdef CONFIG_HIGHMEM max_zone_pfns[ZONE_HIGHMEM ] = max_pfn;#endif +} + +void __init zone_sizes_init (void ) +{ +unsigned long max_zone_pfns[MAX_NR_ZONES ]; + +memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 21/28 xtensa: introduce arch_zone_limits_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated arch_zone_limits_init() function.
Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call free_area_init() from every architecture.
--- arch/xtensa/mm/init.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
arch/xtensa/mm/init.c +10 -6
@@ -116,15 +116,19 @@ static void __init print_vm_layout(void) (unsigned long)(__bss_stop - __bss_start) >> 10); } -void __init zones_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -/* All pages are DMA-able, so we put them all in the DMA zone. */ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = { - [ZONE_NORMAL ] = max_low_pfn, + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn;#ifdef CONFIG_HIGHMEM - [ZONE_HIGHMEM ] = max_pfn, + max_zone_pfns[ZONE_HIGHMEM ] = max_pfn;#endif - }; +} + +void __init zones_init (void ) +{ +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; + +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn);print_vm_layout (); }
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 22/28 arch, mm: consolidate initialization of nodes, zones and memory map
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
To initialize node, zone and memory map data structures every architecture calls free_area_init() during setup_arch() and passes it an array of zone limits.
Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in setup_arch() in certain cases, some only create hugetlb CMA areas in setup_arch() and sometimes hugetlb allocations happen mm_core_init().
With arch_zone_limits_init() helper available now on all architectures it is no longer necessary to call free_area_init() from architecture setup code. Rather core MM initialization can call arch_zone_limits_init() in a single place.
This allows to unify ordering of hugetlb vs memory map allocation and initialization.
Remove the call to free_area_init() from architecture specific code and place it in a new mm_core_init_early() function that is called immediately after setup_arch().
After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures.
As the first step of this consolidation move hugetlb_bootmem_alloc() to mm_core_early_init().
--- arch/alpha/mm/init.c | 9 +-------- arch/arc/mm/init.c | 5 ----- arch/arm/mm/init.c | 16 ---------------- arch/arm64/mm/init.c | 4 ---- arch/csky/kernel/setup.c | 4 ---- arch/hexagon/mm/init.c | 12 ------------ arch/loongarch/include/asm/pgtable.h | 2 -- arch/loongarch/kernel/setup.c | 2 -- arch/loongarch/mm/init.c | 8 -------- arch/m68k/mm/init.c | 3 --- arch/m68k/mm/mcfmmu.c | 3 --- arch/m68k/mm/motorola.c | 6 +----- arch/m68k/mm/sun3mmu.c | 9 --------- arch/microblaze/mm/init.c | 7 ------- arch/mips/loongson64/numa.c | 4 ---- arch/mips/mm/init.c | 5 ----- arch/mips/sgi-ip27/ip27-memory.c | 4 ---- arch/nios2/mm/init.c | 6 ------ arch/openrisc/mm/init.c | 10 ---------- arch/parisc/mm/init.c | 9 --------- arch/powerpc/mm/mem.c | 4 ---- arch/riscv/mm/init.c | 9 --------- arch/s390/mm/init.c | 5 ----- arch/sh/mm/init.c | 5 ----- arch/sparc/mm/init_64.c | 11 ----------- arch/sparc/mm/srmmu.c | 7 ------- arch/um/kernel/mem.c | 5 ----- arch/x86/mm/init.c | 10 ---------- arch/x86/mm/init_32.c | 1 - arch/x86/mm/init_64.c | 2 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 4 ---- include/linux/mm.h | 4 ++-- init/main.c | 1 + mm/mm_init.c | 18 ++++++++++-------- 35 files changed, 15 insertions(+), 200 deletions(-)
arch/alpha/mm/init.c +1 -8
@@ -220,17 +220,10 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn) }/* -* paging_init() sets up the memory map. +* paging_init() initializes the kernel's ZERO_PGE. */ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -/* Initialize mem_map[]. */ -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); - -/* Initialize the kernel's ZERO_PGE. */ memset (absolute_pointer (ZERO_PGE ),0 ,PAGE_SIZE ); }
arch/arc/mm/init.c +0 -5
@@ -102,8 +102,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn)*/ void __init setup_arch_memory (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -setup_initial_init_mm (_text, _etext, _edata, _end);/* first page of system - kernel .vector starts here */
@@ -158,9 +156,6 @@ void __init setup_arch_memory(void) arch_pfn_offset =min (min_low_pfn, min_high_pfn);kmap_init ();#endif /* CONFIG_HIGHMEM */ - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }void __init arch_mm_preinit (void )
arch/arm/mm/init.c +0 -16
@@ -118,15 +118,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn)#endif } -static void __init zone_sizes_init (unsigned long min,unsigned long max_low, -unsigned long max_high) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -#ifdef CONFIG_HAVE_ARCH_PFN_VALID int pfn_valid (unsigned long pfn) {
@@ -222,13 +213,6 @@ void __init bootmem_init(void)* done after the fixed reservations */ sparse_init (); - -/* -* Now free the memory - free_area_init needs -* the sparse mem_map arrays initialized by sparse_init() -* for memmap_init_zone(), otherwise all PFNs are invalid. -*/ -zone_sizes_init (min_low_pfn, max_low_pfn, max_pfn); }/*
arch/arm64/mm/init.c +0 -4
@@ -134,7 +134,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)static void __init dma_limits_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 };phys_addr_t __maybe_unused acpi_zone_dma_limit;phys_addr_t __maybe_unused dt_zone_dma_limit; phys_addr_t __maybe_unused dma32_phys_limit =
@@ -160,9 +159,6 @@ static void __init dma_limits_init(void)#endif if (!arm64_dma_phys_limit) arm64_dma_phys_limit =PHYS_MASK +1 ; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }int pfn_is_map_memory (unsigned long pfn)
arch/csky/kernel/setup.c +0 -4
@@ -63,7 +63,6 @@ static void __init csky_memblock_init(void) {unsigned long lowmem_size =PFN_DOWN (LOWMEM_LIMIT -PHYS_OFFSET_OFFSET );unsigned long sseg_size =PFN_DOWN (SSEG_SIZE -PHYS_OFFSET_OFFSET ); -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };signed long size;memblock_reserve (__pa (_start), _end - _start);
@@ -101,9 +100,6 @@ static void __init csky_memblock_init(void)memblock_set_current_limit (PFN_PHYS (max_low_pfn));dma_contiguous_reserve (0 ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }void __init setup_arch (char **cmdline_p)
arch/hexagon/mm/init.c +0 -12
@@ -66,20 +66,8 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -/* -* In order to set up page allocator "nodes", -* somebody has to call free_area_init() for UMA. -* -* In this mode, we only have one pg_data_t -* structure: contig_mem_data. -*/ static void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn);/* sets up the zonelists and mem_map */ -/* * Set the init_mm descriptors "context" value to point to the * initial kernel segment table's physical address.
arch/loongarch/include/asm/pgtable.h +0 -2
@@ -353,8 +353,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)return pte; } -extern void paging_init (void ); -#define pte_none (pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))#define pte_present (pte) (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE))#define pte_no_exec (pte) (pte_val(pte) & _PAGE_NO_EXEC)
arch/loongarch/kernel/setup.c +0 -2
@@ -621,8 +621,6 @@ void __init setup_arch(char **cmdline_p)prefill_possible_map ();#endif -paging_init (); -#ifdef CONFIG_KASAN kasan_init ();#endif
arch/loongarch/mm/init.c +0 -8
@@ -68,14 +68,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -void __init paging_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -void __ref free_initmem (void ) {free_initmem_default (POISON_FREE_INITMEM );
arch/m68k/mm/init.c +0 -3
@@ -69,13 +69,10 @@ void __init paging_init(void)* page_alloc get different views of the world. */ unsigned long end_mem = memory_end &PAGE_MASK ; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; high_memory = (void *) end_mem; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); -arch_zone_limits_init (max_zone_pfn); - free_area_init(max_zone_pfn); }#endif /* CONFIG_MMU */
arch/m68k/mm/mcfmmu.c +0 -3
@@ -39,7 +39,6 @@ void __init paging_init(void)pte_t *pg_table;unsigned long address, size;unsigned long next_pgtable; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };int i; empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE );
@@ -73,8 +72,6 @@ void __init paging_init(void) } current->mm =NULL ; -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }int cf_tlb_miss (struct pt_regs *regs,int write,int dtlb,int extension_word)
arch/m68k/mm/motorola.c +1 -5
@@ -429,7 +429,6 @@ DECLARE_VM_GET_PAGE_PROT*/ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };unsigned long min_addr, max_addr;unsigned long addr;int i;
@@ -511,12 +510,9 @@ void __init paging_init(void)set_fc (USER_DATA );#ifdef DEBUG -printk ("before free_area_init\n" ); +printk ("before node_set_state\n" );#endif for (i =0 ; i < m68k_num_memory; i++)if (node_present_pages (i))node_set_state (i,N_NORMAL_MEMORY ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }
arch/m68k/mm/sun3mmu.c +0 -9
@@ -41,7 +41,6 @@ void __init paging_init(void)unsigned long address;unsigned long next_pgtable;unsigned long bootmem_end; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };unsigned long size; empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE );
@@ -80,14 +79,6 @@ void __init paging_init(void)mmu_emu_init (bootmem_end); current->mm =NULL ; - -/* memory sizing is a hack stolen from motorola.c.. hope it works for us */ -arch_zone_limits_init (max_zone_pfn); - -/* I really wish I knew why the following change made things better... -- Sam */ -free_area_init (max_zone_pfn); - - }static const pgprot_t protection_map[16 ] = {
arch/microblaze/mm/init.c +0 -7
@@ -69,22 +69,15 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ static void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ];int idx;/* Setup fixmaps */ for (idx =0 ; idx < __end_of_fixed_addresses; idx++)clear_fixmap (idx); -/* Clean every zones */ -memset (zones_size,0 ,sizeof (zones_size)); -#ifdef CONFIG_HIGHMEM highmem_init ();#endif -arch_zone_limits_init (zones_size); -/* We don't have holes in memory map */ -free_area_init (zones_size); }void __init setup_memory (void )
arch/mips/loongson64/numa.c +0 -4
@@ -162,11 +162,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 , }; -pagetable_init (); -arch_zone_limits_init (zones_size); -free_area_init (zones_size); }/* All PCI device belongs to logical Node-0 */
arch/mips/mm/init.c +0 -5
@@ -417,12 +417,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; -pagetable_init (); - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }#ifdef CONFIG_64BIT
arch/mips/sgi-ip27/ip27-memory.c +0 -4
@@ -413,9 +413,5 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 , }; -pagetable_init (); -arch_zone_limits_init (zones_size); -free_area_init (zones_size); }
arch/nios2/mm/init.c +0 -6
@@ -51,15 +51,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -pagetable_init (); pgd_current = swapper_pg_dir; -arch_zone_limits_init (max_zone_pfn); -/* pass the memory from the bootmem allocator to the main allocator */ -free_area_init (max_zone_pfn); -flush_dcache_range ((unsigned long )empty_zero_page, (unsigned long )empty_zero_page +PAGE_SIZE ); }
arch/openrisc/mm/init.c +0 -10
@@ -47,14 +47,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -static void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -extern const char _s_kernel_ro[], _e_kernel_ro[];/*
@@ -145,8 +137,6 @@ void __init paging_init(void)map_ram (); -zone_sizes_init (); -/* self modifying code ;) */ /* Since the old TLB miss handler has been running up until now, * the kernel pages are still all RW, so we can still modify the
arch/parisc/mm/init.c +0 -9
@@ -698,14 +698,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] =PFN_DOWN (memblock_end_of_DRAM ()); } -static void __init parisc_bootmem_free (void ) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -void __init paging_init (void ) {setup_bootmem ();
@@ -716,7 +708,6 @@ void __init paging_init(void)flush_tlb_all_local (NULL );sparse_init (); -parisc_bootmem_free (); } static void alloc_btlb(unsigned long start, unsigned long end, int *slot,
arch/powerpc/mm/mem.c +0 -4
@@ -237,7 +237,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long long total_ram =memblock_phys_mem_size ();phys_addr_t top_of_ram =memblock_end_of_DRAM ();int zone_dma_bits;
@@ -269,9 +268,6 @@ void __init paging_init(void) zone_dma_limit =DMA_BIT_MASK (zone_dma_bits); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -mark_nonram_nosave (); }
arch/riscv/mm/init.c +0 -9
@@ -87,14 +87,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -static void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -#if defined(CONFIG_MMU ) && defined(CONFIG_DEBUG_VM )#define LOG2_SZ_1K ilog2(SZ_1K)
@@ -1443,7 +1435,6 @@ void __init misc_mem_init(void)/* The entire VMEMMAP region has been populated. Flush TLB for this region */ local_flush_tlb_kernel_range (VMEMMAP_START ,VMEMMAP_END );#endif -zone_sizes_init ();arch_reserve_crashkernel ();memblock_dump_all (); }
arch/s390/mm/init.c +0 -5
@@ -97,14 +97,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; -vmem_map_init ();sparse_init (); zone_dma_limit =DMA_BIT_MASK (31 ); -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }void mark_rodata_ro (void )
arch/sh/mm/init.c +0 -5
@@ -271,7 +271,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long vaddr, end; sh_mv.mv_mem_init ();
@@ -325,10 +324,6 @@ void __init paging_init(void)page_table_range_init (vaddr, end, swapper_pg_dir);kmap_coherent_init (); - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }unsigned int mem_init_done =0 ;
arch/sparc/mm/init_64.c +0 -11
@@ -2459,17 +2459,6 @@ void __init paging_init(void)kernel_physical_mapping_init (); - { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - - max_zone_pfns[ZONE_NORMAL ] = end_pfn; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); - } -printk ("Booting Linux...\n" ); }
arch/sparc/mm/srmmu.c +0 -7
@@ -970,13 +970,6 @@ void __init srmmu_paging_init(void)flush_tlb_all ();sparc_context_init (num_contexts); - - { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); - } }void mmu_info (struct seq_file *m)
arch/um/kernel/mem.c +0 -5
@@ -91,16 +91,11 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - empty_zero_page = (unsigned long *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE );if (!empty_zero_page)panic ("%s: Failed to allocate %lu bytes align=%lx\n" , __func__,PAGE_SIZE ,PAGE_SIZE ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }/*
arch/x86/mm/init.c +0 -10
@@ -1011,16 +1011,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)#endif } -void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -__visible DEFINE_PER_CPU_ALIGNED (struct tlb_state ,cpu_tlbstate ) = { .loaded_mm = &init_mm, .next_asid =1 ,
arch/x86/mm/init_32.c +0 -1
@@ -655,7 +655,6 @@ void __init paging_init(void)*/ olpc_dt_build_devicetree ();sparse_init (); -zone_sizes_init (); }/*
arch/x86/mm/init_64.c +0 -2
@@ -843,8 +843,6 @@ void __init paging_init(void)*/ node_clear_state (0 ,N_MEMORY );node_clear_state (0 ,N_NORMAL_MEMORY ); - -zone_sizes_init (); }#define PAGE_UNUSED 0xFD
arch/x86/mm/mm_internal.h +0 -1
@@ -17,7 +17,6 @@ unsigned long kernel_physical_mapping_init(unsigned long start,unsigned long kernel_physical_mapping_change (unsigned long start,unsigned long end,unsigned long page_size_mask); -void zone_sizes_init (void );extern int after_bootmem;
arch/xtensa/mm/init.c +0 -4
@@ -126,10 +126,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init zones_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn);print_vm_layout (); }
include/linux/mm.h +2 -2
@@ -45,6 +45,7 @@ struct pt_regs;struct folio_batch ;void arch_mm_preinit (void ); +void mm_core_init_early (void );void mm_core_init (void );void init_mm_internals (void );
@@ -3536,7 +3537,7 @@ static inline unsigned long get_num_physpages(void) }/* -* Using memblock node mappings, an architecture may initialise its +* FIXME: Using memblock node mappings, an architecture may initialise its * zones, allocate the backing mem_map and account for memory holes in an * architecture independent manner. *
@@ -3551,7 +3552,6 @@ static inline unsigned long get_num_physpages(void)* memblock_add_node(base, size, nid, MEMBLOCK_NONE) * free_area_init(max_zone_pfns); */ -void free_area_init (unsigned long *max_zone_pfn);void arch_zone_limits_init (unsigned long *max_zone_pfn);unsigned long node_map_pfn_alignment (void ); extern unsigned long absent_pages_in_range(unsigned long start_pfn,
init/main.c +1 -0
@@ -1025,6 +1025,7 @@ void start_kernel(void)page_address_init ();pr_notice ("%s" , linux_banner);setup_arch (&command_line); +mm_core_init_early ();/* Static keys and static calls are needed by LSMs */ jump_label_init ();static_call_init ();
mm/mm_init.c +10 -8
@@ -1810,7 +1810,6 @@ static void __init set_high_memory(void)/** * free_area_init - Initialise all pg_data_t and zone data -* @max_zone_pfn: an array of max PFNs for each zone * * This will call free_area_init_node() for each active node in the system. * Using the page ranges provided by memblock_set_node(), the size of each
@@ -1821,17 +1820,14 @@ static void __init set_high_memory(void)* starts where the previous one ended. For example, ZONE_DMA32 starts * at arch_max_dma_pfn. */ -void __init free_area_init (unsigned long *max_zone_pfn) +static void __init free_area_init (void ) { +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };unsigned long start_pfn, end_pfn;int i, nid, zone;bool descending; -/* Record where the zone boundaries are */ -memset (arch_zone_lowest_possible_pfn,0 , -sizeof (arch_zone_lowest_possible_pfn)); -memset (arch_zone_highest_possible_pfn,0 , -sizeof (arch_zone_highest_possible_pfn)); +arch_zone_limits_init (max_zone_pfn); start_pfn =PHYS_PFN (memblock_start_of_DRAM ()); descending =arch_has_descending_max_zone_pfns ();
@@ -2681,13 +2677,19 @@ void __init __weak mem_init(void) { } +void __init mm_core_init_early (void ) +{ +hugetlb_bootmem_alloc (); + +free_area_init (); +} +/* * Set up kernel memory allocators */ void __init mm_core_init (void ) {arch_mm_preinit (); -hugetlb_bootmem_alloc ();/* Initializations relying on SMP setup */ BUILD_BUG_ON (MAX_ZONELISTS >2 );
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 23/28 arch, mm: consolidate initialization of SPARSE memory model
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Every architecture calls sparse_init() during setup_arch() although the data structures created by sparse_init() are not used until the initialization of the core MM.
Beside the code duplication, calling sparse_init() from architecture specific code causes ordering differences of vmemmap and HVO initialization on different architectures.
Move the call to sparse_init() from architecture specific code to free_area_init() to ensure that vmemmap and HVO initialization order is always the same.
--- Documentation/mm/memory-model.rst | 3 --- Documentation/translations/zh_CN/mm/memory-model.rst | 2 -- arch/alpha/kernel/setup.c | 1 - arch/arm/mm/init.c | 6 ------ arch/arm64/mm/init.c | 6 ------ arch/csky/kernel/setup.c | 2 -- arch/loongarch/kernel/setup.c | 8 -------- arch/mips/kernel/setup.c | 11 ----------- arch/parisc/mm/init.c | 2 -- arch/powerpc/include/asm/setup.h | 4 ++++ arch/powerpc/mm/mem.c | 5 ----- arch/powerpc/mm/numa.c | 2 -- arch/riscv/mm/init.c | 1 - arch/s390/mm/init.c | 1 - arch/sh/mm/init.c | 2 -- arch/sparc/mm/init_64.c | 2 -- arch/x86/mm/init_32.c | 1 - arch/x86/mm/init_64.c | 2 -- include/linux/mmzone.h | 2 -- mm/internal.h | 6 ++++++ mm/mm_init.c | 1 + 21 files changed, 11 insertions(+), 59 deletions(-)
Documentation/mm/memory-model.rst +0 -3
@@ -97,9 +97,6 @@ sections: `mem_section` objects and the number of rows is calculated to fit all the memory sections. -The architecture setup code should call sparse_init() to -initialize the memory sections and the memory maps. - With SPARSEMEM there are two possible ways to convert a PFN to the corresponding `struct page` - a "classic sparse" and "sparse vmemmap". The selection is made at build time and it is determined by
Documentation/translations/zh_CN/mm/memory-model.rst +0 -2
@@ -83,8 +83,6 @@ SPARSEMEM模型将物理内存显示为一个部分的集合。一个区段用me 每一行包含价值 `PAGE_SIZE` 的 `mem_section` 对象,行数的计算是为了适应所有的 内存区。 -架构设置代码应该调用sparse_init()来初始化内存区和内存映射。 - 通过SPARSEMEM,有两种可能的方式将PFN转换为相应的 `struct page` --"classic sparse"和 "sparse vmemmap"。选择是在构建时进行的,它由 `CONFIG_SPARSEMEM_VMEMMAP` 的 值决定。
arch/alpha/kernel/setup.c +0 -1
@@ -607,7 +607,6 @@ setup_arch(char **cmdline_p)/* Find our memory. */ setup_memory (kernel_end);memblock_set_bottom_up (true); -sparse_init ();/* First guess at cpu cache sizes. Do this before init_arch. */ determine_cpu_caches (cpu->type);
arch/arm/mm/init.c +0 -6
@@ -207,12 +207,6 @@ void __init bootmem_init(void)early_memtest ((phys_addr_t )min_low_pfn <<PAGE_SHIFT , (phys_addr_t )max_low_pfn <<PAGE_SHIFT ); - -/* -* sparse_init() tries to allocate memory from memblock, so must be -* done after the fixed reservations -*/ -sparse_init (); }/*
arch/arm64/mm/init.c +0 -6
@@ -321,12 +321,6 @@ void __init bootmem_init(void)#endif kvm_hyp_reserve (); - -/* -* sparse_init() tries to allocate memory from memblock, so must be -* done after the fixed reservations -*/ -sparse_init ();dma_limits_init ();/*
arch/csky/kernel/setup.c +0 -2
@@ -123,8 +123,6 @@ void __init setup_arch(char **cmdline_p)setup_smp ();#endif -sparse_init (); -fixaddr_init ();#ifdef CONFIG_HIGHMEM
arch/loongarch/kernel/setup.c +0 -8
@@ -402,14 +402,6 @@ static void __init arch_mem_init(char **cmdline_p)check_kernel_sections_mem (); -/* -* In order to reduce the possibility of kernel panic when failed to -* get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate -* low memory as small as possible before swiotlb_init(), so make -* sparse_init() using top-down allocation. -*/ -memblock_set_bottom_up (false); -sparse_init ();memblock_set_bottom_up (true);swiotlb_init (true,SWIOTLB_VERBOSE );
arch/mips/kernel/setup.c +0 -11
@@ -614,7 +614,6 @@ static void __init bootcmdline_init(void)* kernel but generic memory management system is still entirely uninitialized. * * o bootmem_init() -* o sparse_init() * o paging_init() * o dma_contiguous_reserve() *
@@ -665,16 +664,6 @@ static void __init arch_mem_init(char **cmdline_p)mips_parse_crashkernel ();device_tree_init (); -/* -* In order to reduce the possibility of kernel panic when failed to -* get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate -* low memory as small as possible before plat_swiotlb_setup(), so -* make sparse_init() using top-down allocation. -*/ -memblock_set_bottom_up (false); -sparse_init (); -memblock_set_bottom_up (true); -plat_swiotlb_setup ();dma_contiguous_reserve (PFN_PHYS (max_low_pfn));
arch/parisc/mm/init.c +0 -2
@@ -706,8 +706,6 @@ void __init paging_init(void)fixmap_init ();flush_cache_all_local ();/* start with known state */ flush_tlb_all_local (NULL ); - -sparse_init (); } static void alloc_btlb(unsigned long start, unsigned long end, int *slot,
arch/powerpc/include/asm/setup.h +4 -0
@@ -20,7 +20,11 @@ extern void reloc_got2(unsigned long);void check_for_initrd (void );void mem_topology_setup (void ); +#ifdef CONFIG_NUMA void initmem_init (void ); +#else +static inline void initmem_init (void ) {} +#endif void setup_panic (void );#define ARCH_PANIC_TIMEOUT 180
arch/powerpc/mm/mem.c +0 -5
@@ -182,11 +182,6 @@ void __init mem_topology_setup(void)memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); } -void __init initmem_init (void ) -{ -sparse_init (); -} -/* mark pages that don't exist as nosave */ static int __init mark_nonram_nosave (void ) {
arch/powerpc/mm/numa.c +0 -2
@@ -1213,8 +1213,6 @@ void __init initmem_init(void)setup_node_data (nid, start_pfn, end_pfn); } -sparse_init (); -/* * We need the numa_cpu_lookup_table to be accurate for all CPUs, * even before we online them, so that we can use cpu_to_{node,mem}
arch/riscv/mm/init.c +0 -1
@@ -1430,7 +1430,6 @@ void __init misc_mem_init(void) {early_memtest (min_low_pfn <<PAGE_SHIFT , max_low_pfn <<PAGE_SHIFT );arch_numa_init (); -sparse_init ();#ifdef CONFIG_SPARSEMEM_VMEMMAP /* The entire VMEMMAP region has been populated. Flush TLB for this region */ local_flush_tlb_kernel_range (VMEMMAP_START ,VMEMMAP_END );
arch/s390/mm/init.c +0 -1
@@ -98,7 +98,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) {vmem_map_init (); -sparse_init (); zone_dma_limit =DMA_BIT_MASK (31 ); }
arch/sh/mm/init.c +0 -2
@@ -227,8 +227,6 @@ static void __init do_init_bootmem(void)node_set_online (0 );plat_mem_setup (); - -sparse_init (); }static void __init early_reserve_mem (void )
arch/sparc/mm/init_64.c +0 -2
@@ -1615,8 +1615,6 @@ static unsigned long __init bootmem_init(unsigned long phys_base)/* XXX cpu notifier XXX */ -sparse_init (); -return end_pfn; }
arch/x86/mm/init_32.c +0 -1
@@ -654,7 +654,6 @@ void __init paging_init(void)* NOTE: at this point the bootmem allocator is fully available. */ olpc_dt_build_devicetree (); -sparse_init (); }/*
arch/x86/mm/init_64.c +0 -2
@@ -833,8 +833,6 @@ void __init initmem_init(void)void __init paging_init (void ) { -sparse_init (); -/* * clear the default setting with node 0 * note: don't use nodes_clear here, that is really clearing when
include/linux/mmzone.h +0 -2
@@ -2285,9 +2285,7 @@ static inline unsigned long next_present_section_nr(unsigned long section_nr)#define pfn_to_nid (pfn) (0)#endif -void sparse_init (void );#else -#define sparse_init () do {} while (0)#define sparse_index_init (_sec, _nid) do {} while (0)#define sparse_vmemmap_init_nid_early (_nid) do {} while (0)#define sparse_vmemmap_init_nid_late (_nid) do {} while (0)
mm/internal.h +6 -0
@@ -860,6 +860,12 @@ void memmap_init_range(unsigned long, int, unsigned long, unsigned long, unsigned long, enum meminit_context, struct vmem_altmap *, int, bool); +#ifdef CONFIG_SPARSEMEM +void sparse_init (void ); +#else +static inline void sparse_init (void ) {} +#endif /* CONFIG_SPARSEMEM */ +#if definedCONFIG_COMPACTION || definedCONFIG_CMA /*
mm/mm_init.c +1 -0
@@ -1828,6 +1828,7 @@ static void __init free_area_init(void)bool descending;arch_zone_limits_init (max_zone_pfn); +sparse_init (); start_pfn =PHYS_PFN (memblock_start_of_DRAM ()); descending =arch_has_descending_max_zone_pfns ();
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 24/28 mips: drop paging_init()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
All three variants of paging_init() on MIPS are wrappers for pagetable_init().
Instead of having three identical wrappers, call pagetable_init() directly from setup_arch() and remove the unnecessary paging_init() functions.
--- arch/mips/include/asm/pgalloc.h | 2 -- arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 4 ++-- arch/mips/loongson64/numa.c | 5 ----- arch/mips/mm/init.c | 5 ----- arch/mips/sgi-ip27/ip27-memory.c | 5 ----- 6 files changed, 3 insertions(+), 20 deletions(-)
arch/mips/include/asm/pgalloc.h +0 -2
@@ -101,6 +101,4 @@ static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4d, pud_t *pud)#endif /* __PAGETABLE_PUD_FOLDED */ -extern void pagetable_init (void ); -#endif /* _ASM_PGALLOC_H */
arch/mips/include/asm/pgtable.h +1 -1
@@ -56,7 +56,7 @@ extern unsigned long zero_page_mask; (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))#define __HAVE_COLOR_ZERO_PAGE -extern void paging_init (void ); +extern void pagetable_init (void );/* * Conversion functions: convert a page and protection to a page entry,
arch/mips/kernel/setup.c +2 -2
@@ -614,7 +614,7 @@ static void __init bootcmdline_init(void)* kernel but generic memory management system is still entirely uninitialized. * * o bootmem_init() -* o paging_init() +* o pagetable_init() * o dma_contiguous_reserve() * * At this stage the bootmem allocator is ready to use.
@@ -778,7 +778,7 @@ void __init setup_arch(char **cmdline_p)prefill_possible_map ();cpu_cache_init (); -paging_init (); +pagetable_init ();memblock_dump_all ();
arch/mips/loongson64/numa.c +0 -5
@@ -160,11 +160,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -void __init paging_init (void ) -{ -pagetable_init (); -} -/* All PCI device belongs to logical Node-0 */ int pcibus_to_node (struct pci_bus *bus) {
arch/mips/mm/init.c +0 -5
@@ -415,11 +415,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)#endif } -void __init paging_init (void ) -{ -pagetable_init (); -} -#ifdef CONFIG_64BIT static struct kcore_list kcore_kseg0;#endif
arch/mips/sgi-ip27/ip27-memory.c +0 -5
@@ -410,8 +410,3 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) { max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } - -void __init paging_init (void ) -{ -pagetable_init (); -}
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 25/28 x86: don't reserve hugetlb memory in setup_arch()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Commit 665eaf313314 ("x86/setup: call hugetlb_bootmem_alloc early") added an early call to hugetlb_bootmem_alloc() to setup_arch() to allow HVO style pre-initialization of vmemmap on x86.
With the ordering of hugetlb reservation vs memory map initialization sorted out in core MM this no longer needs to be an architecture specific quirk.
Drop the call to hugetlb_bootmem_alloc() from x86::setup_arch().
--- arch/x86/kernel/setup.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/setup.c +0 -1
@@ -1191,7 +1191,6 @@ void __init setup_arch(char **cmdline_p)if (boot_cpu_has (X86_FEATURE_GBPAGES )) {hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); -hugetlb_bootmem_alloc (); }/*
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 26/28 mm, arch: consolidate hugetlb CMA reservation
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
Every architecture that supports hugetlb_cma command line parameter reserves CMA areas for hugetlb during setup_arch().
This obfuscates the ordering of hugetlb CMA initialization with respect to the rest initialization of the core MM.
Introduce arch_hugetlb_cma_order() callback to allow architectures report the desired order-per-bit of CMA areas and provide a week implementation of arch_hugetlb_cma_order() for architectures that don't support hugetlb with CMA.
Use this callback in hugetlb_cma_reserve() instead if passing the order as parameter and call hugetlb_cma_reserve() from mm_core_init_early() rather than have it spread over architecture specific code.
--- .../driver-api/cxl/linux/early-boot.rst | 2 +- arch/arm64/include/asm/hugetlb.h | 2 -- arch/arm64/mm/hugetlbpage.c | 10 +++------- arch/arm64/mm/init.c | 9 --------- arch/powerpc/include/asm/hugetlb.h | 5 ----- arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++++------- arch/riscv/mm/hugetlbpage.c | 8 ++++++++ arch/riscv/mm/init.c | 2 -- arch/s390/kernel/setup.c | 2 -- arch/s390/mm/hugetlbpage.c | 8 ++++++++ arch/x86/kernel/setup.c | 4 ---- arch/x86/mm/hugetlbpage.c | 8 ++++++++ include/linux/hugetlb.h | 6 ++++-- mm/hugetlb_cma.c | 19 ++++++++++++++----- mm/mm_init.c | 1 + 16 files changed, 51 insertions(+), 47 deletions(-)
Documentation/driver-api/cxl/linux/early-boot.rst +1 -1
@@ -125,7 +125,7 @@ The contiguous memory allocator (CMA) enables reservation of contiguous memory regions on NUMA nodes during early boot. However, CMA cannot reserve memory on NUMA nodes that are not online during early boot. :: - void __init hugetlb_cma_reserve(int order) { + void __init hugetlb_cma_reserve(void) { if (!node_online(nid)) /* do not allow reservations */ }
arch/arm64/include/asm/hugetlb.h +0 -2
@@ -56,8 +56,6 @@ extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr,#define __HAVE_ARCH_HUGE_PTEP_GETextern pte_t huge_ptep_get (struct mm_struct *mm,unsigned long addr,pte_t *ptep); -void __init arm64_hugetlb_cma_reserve (void ); -#define huge_ptep_modify_prot_start huge_ptep_modify_prot_startextern pte_t huge_ptep_modify_prot_start (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep);
arch/arm64/mm/hugetlbpage.c +3 -7
@@ -36,16 +36,12 @@* huge pages could still be served from those areas. */ #ifdef CONFIG_CMA -void __init arm64_hugetlb_cma_reserve (void ) +unsigned int arch_hugetlb_cma_order (void ) { -int order; -if (pud_sect_supported ()) - order =PUD_SHIFT -PAGE_SHIFT ; -else - order =CONT_PMD_SHIFT -PAGE_SHIFT ; +return PUD_SHIFT -PAGE_SHIFT ; -hugetlb_cma_reserve (order); +return CONT_PMD_SHIFT -PAGE_SHIFT ; }#endif /* CONFIG_CMA */
arch/arm64/mm/init.c +0 -9
@@ -311,15 +311,6 @@ void __init bootmem_init(void)arch_numa_init (); -/* -* must be done after arch_numa_init() which calls numa_init() to -* initialize node_online_map that gets used in hugetlb_cma_reserve() -* while allocating required CMA size across online nodes. -*/ -#if defined(CONFIG_HUGETLB_PAGE ) && defined(CONFIG_CMA ) -arm64_hugetlb_cma_reserve (); -#endif -kvm_hyp_reserve ();dma_limits_init ();
arch/powerpc/include/asm/hugetlb.h +0 -5
@@ -68,7 +68,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte, int dirty); -void gigantic_hugetlb_cma_reserve (void )__init ;#include <asm-generic/hugetlb.h> #else /* ! CONFIG_HUGETLB_PAGE */
@@ -77,10 +76,6 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma, { } -static inline void __init gigantic_hugetlb_cma_reserve (void ) -{ -} -static inline void __init hugetlbpage_init_defaultsize (void ) { }
arch/powerpc/kernel/setup-common.c +0 -1
@@ -1003,7 +1003,6 @@ void __init setup_arch(char **cmdline_p)fadump_cma_init ();kdump_cma_reserve ();kvm_cma_reserve (); -gigantic_hugetlb_cma_reserve ();early_memtest (min_low_pfn <<PAGE_SHIFT , max_low_pfn <<PAGE_SHIFT );
arch/powerpc/mm/hugetlbpage.c +4 -7
@@ -200,18 +200,15 @@ static int __init hugetlbpage_init(void)arch_initcall (hugetlbpage_init); -void __init gigantic_hugetlb_cma_reserve (void ) +unsigned int __init arch_hugetlb_cma_order (void ) { -unsigned long order =0 ; -if (radix_enabled ()) - order =PUD_SHIFT -PAGE_SHIFT ; +return PUD_SHIFT -PAGE_SHIFT ;else if (!firmware_has_feature (FW_FEATURE_LPAR ) && mmu_psize_defs[MMU_PAGE_16G ].shift)/* * For pseries we do use ibm,expected#pages for reserving 16G pages. */ - order =mmu_psize_to_shift (MMU_PAGE_16G ) -PAGE_SHIFT ; +return mmu_psize_to_shift (MMU_PAGE_16G ) -PAGE_SHIFT ; -if (order) -hugetlb_cma_reserve (order); +return 0 ; }
arch/riscv/mm/hugetlbpage.c +8 -0
@@ -447,3 +447,11 @@ static __init int gigantic_pages_init(void) }arch_initcall (gigantic_pages_init);#endif + +unsigned int __init arch_hugetlb_cma_order (void ) +{ +if (IS_ENABLED (CONFIG_64BIT )) +return PUD_SHIFT -PAGE_SHIFT ; + +return 0 ; +}
arch/riscv/mm/init.c +0 -2
@@ -311,8 +311,6 @@ static void __init setup_bootmem(void)memblock_reserve (dtb_early_pa,fdt_totalsize (dtb_early_va));dma_contiguous_reserve (dma32_phys_limit); -if (IS_ENABLED (CONFIG_64BIT )) -hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); }#ifdef CONFIG_RELOCATABLE
arch/s390/kernel/setup.c +0 -2
@@ -963,8 +963,6 @@ void __init setup_arch(char **cmdline_p)setup_uv ();dma_contiguous_reserve (ident_map_size);vmcp_cma_reserve (); -if (cpu_has_edat2 ()) -hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT );reserve_crashkernel ();#ifdef CONFIG_CRASH_DUMP
arch/s390/mm/hugetlbpage.c +8 -0
@@ -255,3 +255,11 @@ bool __init arch_hugetlb_valid_size(unsigned long size)else return false; } + +unsigned int __init arch_hugetlb_cma_order (void ) +{ +if (cpu_has_edat2 ()) +return PUD_SHIFT -PAGE_SHIFT ; + +return 0 ; +}
arch/x86/kernel/setup.c +0 -4
@@ -1189,10 +1189,6 @@ void __init setup_arch(char **cmdline_p)initmem_init ();dma_contiguous_reserve (max_pfn_mapped <<PAGE_SHIFT ); -if (boot_cpu_has (X86_FEATURE_GBPAGES )) { -hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); - } -/* * Reserve memory for crash kernel after SRAT is parsed so that it * won't consume hotpluggable memory.
arch/x86/mm/hugetlbpage.c +8 -0
@@ -42,3 +42,11 @@ static __init int gigantic_pages_init(void)arch_initcall (gigantic_pages_init);#endif #endif + +unsigned int __init arch_hugetlb_cma_order (void ) +{ +if (boot_cpu_has (X86_FEATURE_GBPAGES )) +return PUD_SHIFT -PAGE_SHIFT ; + +return 0 ; +}
include/linux/hugetlb.h +4 -2
@@ -279,6 +279,8 @@ void fixup_hugetlb_reservations(struct vm_area_struct *vma);void hugetlb_split (struct vm_area_struct *vma,unsigned long addr);int hugetlb_vma_lock_alloc (struct vm_area_struct *vma); +unsigned int arch_hugetlb_cma_order (void ); +#else /* !CONFIG_HUGETLB_PAGE */ static inline void hugetlb_dup_vma_private (struct vm_area_struct *vma)
@@ -1316,9 +1318,9 @@ static inline spinlock_t *huge_pte_lock(struct hstate *h, }#if defined(CONFIG_HUGETLB_PAGE ) && defined(CONFIG_CMA ) -extern void __init hugetlb_cma_reserve (int order); +extern void __init hugetlb_cma_reserve (void );#else -static inline __init void hugetlb_cma_reserve (int order) +static inline __init void hugetlb_cma_reserve (void ) { }#endif
mm/hugetlb_cma.c +14 -5
@@ -134,12 +134,24 @@ static int __init cmdline_parse_hugetlb_cma_only(char *p)early_param ("hugetlb_cma_only" , cmdline_parse_hugetlb_cma_only); -void __init hugetlb_cma_reserve (int order) +unsigned int __weak arch_hugetlb_cma_order (void ) { -unsigned long size, reserved, per_node; +return 0 ; +} + +void __init hugetlb_cma_reserve (void ) +{ +unsigned long size, reserved, per_node, order;bool node_specific_cma_alloc = false;int nid; +if (!hugetlb_cma_size) +return ; + + order =arch_hugetlb_cma_order (); +if (!order) +return ; +/* * HugeTLB CMA reservation is required for gigantic * huge pages which could not be allocated via the
@@ -149,9 +161,6 @@ void __init hugetlb_cma_reserve(int order)VM_WARN_ON (order <=MAX_PAGE_ORDER ); cma_reserve_called = true; -if (!hugetlb_cma_size) -return ; -hugetlb_bootmem_set_nodes ();for (nid =0 ; nid <MAX_NUMNODES ; nid++) {
mm/mm_init.c +1 -0
@@ -2680,6 +2680,7 @@ void __init __weak mem_init(void)void __init mm_core_init_early (void ) { +hugetlb_cma_reserve ();hugetlb_bootmem_alloc ();free_area_init ();
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 27/28 mm/hugetlb: drop hugetlb_cma_check()
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
hugetlb_cma_check() was required when the ordering of hugetlb_cma_reserve() and hugetlb_bootmem_alloc() was architecture depended.
Since hugetlb_cma_reserve() is always called before hugetlb_bootmem_alloc() there is no need to check whether hugetlb_cma_reserve() was already called.
Drop unneeded hugetlb_cma_check() function.
--- mm/hugetlb.c | 1 - mm/hugetlb_cma.c | 16 +++------------- mm/hugetlb_cma.h | 5 ----- 3 files changed, 3 insertions(+), 19 deletions(-)
mm/hugetlb.c +0 -1
@@ -4159,7 +4159,6 @@ static int __init hugetlb_init(void) } } -hugetlb_cma_check ();hugetlb_init_hstates ();gather_bootmem_prealloc ();report_hugepages ();
mm/hugetlb_cma.c +3 -13
@@ -85,9 +85,6 @@ hugetlb_cma_alloc_bootmem(struct hstate *h, int *nid, bool node_exact)return m; } - -static bool cma_reserve_called__initdata ; -static int __init cmdline_parse_hugetlb_cma (char *p) {int nid, count =0 ;
@@ -149,8 +146,10 @@ void __init hugetlb_cma_reserve(void)return ; order =arch_hugetlb_cma_order (); -if (!order) +if (!order) { +pr_warn ("hugetlb_cma: the option isn't supported by current arch\n" );return ; + }/* * HugeTLB CMA reservation is required for gigantic
@@ -159,7 +158,6 @@ void __init hugetlb_cma_reserve(void)* breaking this assumption. */ VM_WARN_ON (order <=MAX_PAGE_ORDER ); - cma_reserve_called = true;hugetlb_bootmem_set_nodes ();
@@ -253,14 +251,6 @@ void __init hugetlb_cma_reserve(void) hugetlb_cma_size =0 ; } -void __init hugetlb_cma_check (void ) -{ -if (!hugetlb_cma_size || cma_reserve_called) -return ; - -pr_warn ("hugetlb_cma: the option isn't supported by current arch\n" ); -} -bool hugetlb_cma_exclusive_alloc (void ) {return hugetlb_cma_only;
mm/hugetlb_cma.h +0 -5
@@ -8,7 +8,6 @@ struct folio *hugetlb_cma_alloc_folio(int order, gfp_t gfp_mask, int nid, nodemask_t *nodemask);struct huge_bootmem_page *hugetlb_cma_alloc_bootmem (struct hstate *h,int *nid,bool node_exact); -void hugetlb_cma_check (void );bool hugetlb_cma_exclusive_alloc (void );unsigned long hugetlb_cma_total_size (void );void hugetlb_cma_validate_params (void );
@@ -31,10 +30,6 @@ struct huge_bootmem_page *hugetlb_cma_alloc_bootmem(struct hstate *h, int *nid,return NULL ; } -static inline void hugetlb_cma_check (void ) -{ -} -static inline bool hugetlb_cma_exclusive_alloc (void ) {return false;
Signature · 1 line
2.51.0
Mike Rapoport
maintainerPATCH v2 28/28 Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc"
In reply to Mike RapoportFrom: "Mike Rapoport (Microsoft)" <[email protected]>
This reverts commit d58b2498200724e4f8c12d71a5953da03c8c8bdf.
hugetlb_bootmem_alloc() is called only once, no need to check if it was called already at its entry.
Other checks performed during HVO initialization are also no longer necessary because sparse_init() that calls hugetlb_vmemmap_init_early() and hugetlb_vmemmap_init_late() is always called after hugetlb_bootmem_alloc().
--- include/linux/hugetlb.h | 6 ------ mm/hugetlb.c | 12 ------------ mm/hugetlb_vmemmap.c | 11 ----------- 3 files changed, 29 deletions(-)
include/linux/hugetlb.h +0 -6
@@ -175,7 +175,6 @@ extern int sysctl_hugetlb_shm_group __read_mostly;extern struct list_head huge_boot_pages[MAX_NUMNODES ];void hugetlb_bootmem_alloc (void ); -bool hugetlb_bootmem_allocated (void );extern nodemask_t hugetlb_bootmem_nodes;void hugetlb_bootmem_set_nodes (void );
@@ -1300,11 +1299,6 @@ static inline bool hugetlbfs_pagecache_present(static inline void hugetlb_bootmem_alloc (void ) { } - -static inline bool hugetlb_bootmem_allocated (void ) -{ -return false; -}#endif /* CONFIG_HUGETLB_PAGE */ static inline spinlock_t *huge_pte_lock(struct hstate *h,
mm/hugetlb.c +0 -12
@@ -4470,21 +4470,11 @@ void __init hugetlb_bootmem_set_nodes(void) } } -static bool __hugetlb_bootmem_allocated__initdata ; - -bool __init hugetlb_bootmem_allocated (void ) -{ -return __hugetlb_bootmem_allocated; -} -void __init hugetlb_bootmem_alloc (void ) {struct hstate *h;int i; -if (__hugetlb_bootmem_allocated) -return ; -hugetlb_bootmem_set_nodes ();for (i =0 ; i <MAX_NUMNODES ; i++)
@@ -4498,8 +4488,6 @@ void __init hugetlb_bootmem_alloc(void)if (hstate_is_gigantic (h))hugetlb_hstate_alloc_pages (h); } - - __hugetlb_bootmem_allocated = true; }/*
mm/hugetlb_vmemmap.c +0 -11
@@ -794,14 +794,6 @@ void __init hugetlb_vmemmap_init_early(int nid)struct huge_bootmem_page *m =NULL ;void *map; -/* -* Noting to do if bootmem pages were not allocated -* early in boot, or if HVO wasn't enabled in the -* first place. -*/ -if (!hugetlb_bootmem_allocated ()) -return ; -if (!READ_ONCE (vmemmap_optimize_enabled))return ;
@@ -847,9 +839,6 @@ void __init hugetlb_vmemmap_init_late(int nid)struct hstate *h;void *map; -if (!hugetlb_bootmem_allocated ()) -return ; -if (!READ_ONCE (vmemmap_optimize_enabled))return ;
Signature · 1 line
2.51.0
Quoted 142 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Hi,
Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters.
Some architectures rely on the core MM to call
hugetlb_bootmem_alloc()while others call it very early to allow pre-allocation of HVO-style vmemmap.When
hugetlb_cmais supported by an architecture it is initialized duringsetup_arch()and then laterhugetlb_initcode needs to understand did it happen or not.To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations.
This required pulling out the call to
free_area_init()out ofsetup_arch()path and moving it MM initialization and this is what the first 23 patches do.These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to
free_area_init()andsprase_init()fromarch/*.Patch 24 is a simple cleanup for MIPS.
Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups.
I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back.
The changes also available in git:
https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v2v2 changes:
* move the hugetlb and memory map initializaion tomm_core_init_early()
* add Acksv1: https://lore.kernel.org/all/[email protected]
Mike Rapoport (Microsoft) (28):
alpha: introducearch_zone_limits_init()
arc: introducearch_zone_limits_init()
arm: introducearch_zone_limits_init()
arm64: introducearch_zone_limits_init()
csky: introducearch_zone_limits_init()
hexagon: introducearch_zone_limits_init()
loongarch: introducearch_zone_limits_init()
m68k: introducearch_zone_limits_init()
microblaze: introducearch_zone_limits_init()
mips: introducearch_zone_limits_init()
nios2: introducearch_zone_limits_init()
openrisc: introducearch_zone_limits_init()
parisc: introducearch_zone_limits_init()
powerpc: introducearch_zone_limits_init()
riscv: introducearch_zone_limits_init()
s390: introducearch_zone_limits_init()
sh: introducearch_zone_limits_init()
sparc: introducearch_zone_limits_init()
um: introducearch_zone_limits_init()
x86: introducearch_zone_limits_init()
xtensa: introducearch_zone_limits_init()
arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model
mips: droppaging_init()
x86: don't reserve hugetlb memory insetup_arch()
mm, arch: consolidate hugetlb CMA reservation
mm/hugetlb: drophugetlb_cma_check()
Revert "mm/hugetlb: deal with multiple calls tohugetlb_bootmem_alloc".../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/mm/init.c | 25 ++---------- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 61 files changed, 219 insertions(+), 394 deletions(-)
Quoted 4 lines
base-commit:
8f0b4cce4481fb22653697cced8d0d04027cb1e8--
2.51.0
Thanks for this series. When I introduced HVO pre-init, I noticed the inconsistencies in init order, but shied away from attempting any general cleanup, as I had only tested pre-init on x86.
With this, it should be possible to enable ARCH_WANT_HUGETLB_VMEMMAP_PREINIT on architectures that support HVO. I think that's only riscv and loongarch right now. But that's out of scope here, though.
- Frank
Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
In reply to Mike RapoportHi,
Quoted 24 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
To initialize node, zone and memory map data structures every architecture calls
free_area_init()duringsetup_arch()and passes it an array of zone limits.Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in
setup_arch()in certain cases, some only create hugetlb CMA areas insetup_arch()and sometimes hugetlb allocations happenmm_core_init().With
arch_zone_limits_init()helper available now on all architectures it is no longer necessary to callfree_area_init()from architecture setup code. Rather core MM initialization can callarch_zone_limits_init()in a single place.This allows to unify ordering of hugetlb vs memory map allocation and initialization.
Remove the call to
free_area_init()from architecture specific code and place it in a newmm_core_init_early()function that is called immediately aftersetup_arch().
Quoted 8 lines
After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures.
As the first step of this consolidation move
hugetlb_bootmem_alloc()tomm_core_early_init().Signed-off-by Mike Rapoport (Microsoft) <[email protected]>
This breaks boot on my Raspberry Pi 1. The reason seems to be the use of page_folio() when initializing the dynamically allocated zero page in arm, which doesn't work when free_area_init() hasn't been called yet.
The following oopses are generated:
Booting Linux on physical CPU 0x0
Linux version 6.19.0-rc3-03898-g7975b0084358 ([email protected]) (armv6j-unknown-linux-gnueabihf-gcc (Gentoo 15.2.1_p20251122 p3) 15.2.1 20251122, GNU ld (Gentoo 2.45.1 p1) 2.45.1) #451 Fri Jan 2 20:26:00 CET 2026
CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt: Machine model: Raspberry Pi Model B Rev 2
earlycon: pl11 at MMIO32 0x20201000 (options '')
printk: legacy bootconsole [pl11] enabled
Memory policy: Data cache writeback
Reserved memory: created CMA memory pool at 0x19400000, size 64 MiB
OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
OF: reserved mem: 0x19400000..0x1d3fffff (65536 KiB) map reusable linux,cma
8<--- cut here ---
Unable to handle kernel paging request at virtual address 003dfb44 when read [003dfb44] *pgd=00000000 Internal error: Oops: 5 [#1] ARM CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.19.0-rc3-03898-g7975b0084358 #451 NONE Hardware name: BCM2835 PC is at paging_init (include/linux/page-flags.h:284 (discriminator 2) arch/arm/mm/mmu.c:1790 (discriminator 2)) LR is at paging_init (arch/arm/mm/mmu.c:1789 (discriminator 1)) pc : lr : psr: 600000d3 sp : c0d01ef8 ip : defdb000 fp : 0000000b r10: 00200000 r9 : d9400000 r8 : ffe00000 r7 : c0d09050 r6 : c0d0902c r5 : c0d43d40 r4 : 0001efda r3 : c0dab20c r2 : 00000000 r1 : 003dfb40 r0 : 00000000 Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment none Control: 00c5387d Table: 00004008 DAC: 00000051 Register r0 information: NULL pointer Register r1 information: non-paged memory Register r2 information: NULL pointer Register r3 information: 8<--- cut here --- Unable to handle kernel paging request at virtual address 0001b564 when read [0001b564] *pgd=00000000 Internal error: Oops: 5 [#2] ARM CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.19.0-rc3-03898-g7975b0084358 #451 NONE Hardware name: BCM2835 PC is at kmem_dump_obj (mm/slab.h:142 (discriminator 2) mm/slab.h:178 (discriminator 2) mm/slab_common.c:609 (discriminator 2)) LR is at 0x1 pc : lr : psr: 200001d3 sp : c0d01cc8 ip : 00000000 fp : 0000000b r10: 00200000 r9 : c0dab1dc r8 : 00000000 r7 : 00000005 r6 : 00000dab r5 : 0001b560 r4 : c0dab20c r3 : c0dc2058 r2 : 1f000000 r1 : 00c00000 r0 : 00000001 Flags: nzCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment none Control: 00c5387d Table: 00004008 DAC: 00000051 Register r0 information: non-paged memory Register r1 information: non-paged memory Register r2 information: non-paged memory Register r3 information: 8<--- cut here ---
and the second one repeats for some time afterwards.
I experimented a little by allocating the zero page statically as many other arches do which fixes the issue as it does not need to be initialized at this point anymore, though I have no idea if that's appropriate.
Regards,
Klara Modin
...
Quoted 34 lines
arch/arm/mm/init.c +0
-16@@ -118,15 +118,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn)#endif } -static void __init zone_sizes_init (unsigned long min,unsigned long max_low, -unsigned long max_high) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -#ifdef CONFIG_HAVE_ARCH_PFN_VALID int pfn_valid (unsigned long pfn) {@@ -222,13 +213,6 @@ void __init bootmem_init(void)* done after the fixed reservations */ sparse_init (); - -/* -* Now free the memory - free_area_init needs -* the sparse mem_map arrays initialized by sparse_init() -* for memmap_init_zone(), otherwise all PFNs are invalid. -*/ -zone_sizes_init (min_low_pfn, max_low_pfn, max_pfn); }/*
...
Quoted 98 lines
include/linux/mm.h +2
-2@@ -45,6 +45,7 @@ struct pt_regs;struct folio_batch ;void arch_mm_preinit (void ); +void mm_core_init_early (void );void mm_core_init (void );void init_mm_internals (void );@@ -3536,7 +3537,7 @@ static inline unsigned long get_num_physpages(void) }/* -* Using memblock node mappings, an architecture may initialise its +* FIXME: Using memblock node mappings, an architecture may initialise its * zones, allocate the backing mem_map and account for memory holes in an * architecture independent manner. * @@ -3551,7 +3552,6 @@ static inline unsigned long get_num_physpages(void)* memblock_add_node(base, size, nid, MEMBLOCK_NONE) * free_area_init(max_zone_pfns); */ -void free_area_init (unsigned long *max_zone_pfn);void arch_zone_limits_init (unsigned long *max_zone_pfn);unsigned long node_map_pfn_alignment (void ); extern unsigned long absent_pages_in_range(unsigned long start_pfn,init/main.c +1
-0@@ -1025,6 +1025,7 @@ void start_kernel(void)page_address_init ();pr_notice ("%s" , linux_banner);setup_arch (&command_line); +mm_core_init_early ();/* Static keys and static calls are needed by LSMs */ jump_label_init ();static_call_init ();mm/mm_init.c +10
-8@@ -1810,7 +1810,6 @@ static void __init set_high_memory(void)/** * free_area_init - Initialise all pg_data_t and zone data -* @max_zone_pfn: an array of max PFNs for each zone * * This will call free_area_init_node() for each active node in the system. * Using the page ranges provided by memblock_set_node(), the size of each @@ -1821,17 +1820,14 @@ static void __init set_high_memory(void)* starts where the previous one ended. For example, ZONE_DMA32 starts * at arch_max_dma_pfn. */ -void __init free_area_init (unsigned long *max_zone_pfn) +static void __init free_area_init (void ) { +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };unsigned long start_pfn, end_pfn;int i, nid, zone;bool descending; -/* Record where the zone boundaries are */ -memset (arch_zone_lowest_possible_pfn,0 , -sizeof (arch_zone_lowest_possible_pfn)); -memset (arch_zone_highest_possible_pfn,0 , -sizeof (arch_zone_highest_possible_pfn)); +arch_zone_limits_init (max_zone_pfn); start_pfn =PHYS_PFN (memblock_start_of_DRAM ()); descending =arch_has_descending_max_zone_pfns ();@@ -2681,13 +2677,19 @@ void __init __weak mem_init(void) { } +void __init mm_core_init_early (void ) +{ +hugetlb_bootmem_alloc (); + +free_area_init (); +} +/* * Set up kernel memory allocators */ void __init mm_core_init (void ) {arch_mm_preinit (); -hugetlb_bootmem_alloc ();/* Initializations relying on SMP setup */ BUILD_BUG_ON (MAX_ZONELISTS >2 );Signature · 1 line
2.51.0
Re: [PATCH v2 12/28] openrisc: introduce arch_zone_limits_init()
In reply to Mike RapoportQuoted 31 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated
arch_zone_limits_init()function.Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call
free_area_init()from every architecture.Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- arch/openrisc/mm/init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)arch/openrisc/mm/init.c +1
-4@@ -39,15 +39,19 @@int mem_init_done; -static void __init zone_sizes_init (void ) +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -/* * We use only ZONE_NORMAL */ - max_zone_pfn[ZONE_NORMAL ] = max_low_pfn;
arch/openrisc/mm/init.c line 56
Quoted 10 lines
arch/openrisc/mm/init.c +7
-0+ max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +} + +static void __init zone_sizes_init (void ) +{ +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; +arch_zone_limits_init (max_zone_pfn);free_area_init (max_zone_pfn); }
Thanks, this looks like a good cleanup.
Mike Rapoport
maintainerRe: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
In reply to Klara ModinHi,
Quoted 29 lines · Klara Modin
Quoted 28 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
To initialize node, zone and memory map data structures every architecture calls
free_area_init()duringsetup_arch()and passes it an array of zone limits.Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in
setup_arch()in certain cases, some only create hugetlb CMA areas insetup_arch()and sometimes hugetlb allocations happenmm_core_init().With
arch_zone_limits_init()helper available now on all architectures it is no longer necessary to callfree_area_init()from architecture setup code. Rather core MM initialization can callarch_zone_limits_init()in a single place.This allows to unify ordering of hugetlb vs memory map allocation and initialization.
Remove the call to
free_area_init()from architecture specific code and place it in a newmm_core_init_early()function that is called immediately aftersetup_arch().After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures.
Quoted 8 lines
Quoted 4 lines
As the first step of this consolidation move
hugetlb_bootmem_alloc()tomm_core_early_init().Signed-off-by Mike Rapoport (Microsoft) <[email protected]>This breaks boot on my Raspberry Pi 1. The reason seems to be the use of
page_folio()when initializing the dynamically allocated zero page in arm, which doesn't work whenfree_area_init()hasn't been called yet.
I believe the reason is rather the use of virt_to_phys() that now happens before the memory map is ready.
Quoted 10 lines
The following oopses are generated:
8<--- cut here ---
Unable to handle kernel paging request at virtual address 003dfb44 when read [003dfb44] *pgd=00000000 Internal error: Oops: 5 [#1] ARM CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.19.0-rc3-03898-g7975b0084358 #451 NONE Hardware name: BCM2835 PC is at paging_init (include/linux/page-flags.h:284 (discriminator 2) arch/arm/mm/mmu.c:1790 (discriminator 2)) LR is at paging_init (arch/arm/mm/mmu.c:1789 (discriminator 1))
...
Quoted 8 lines
8<--- cut here ---
and the second one repeats for some time afterwards.
I experimented a little by allocating the zero page statically as many other arches do which fixes the issue as it does not need to be initialized at this point anymore, though I have no idea if that's appropriate.
Do you mean putting the zero in the BSS like, e.g. arm64? I don't see a reason why this shouldn't work.
I also have a patch with some minor changes that still keeps empty_zero_page allocated, but avoids virt_to_page() and folio_page() dance. Can you please test it in your setup?
From 8a213c13211106d592fbe96b68ee29879ed739f8 Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (Microsoft)" <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory map
Unlike most architectures, arm keeps a struct page pointer to the empty_zero_page and to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating the empty_zero_page.
Make empty_zero_page a void * to decouple it's initialization from the initialization of the memory map.
--- arch/arm/include/asm/pgtable.h | 4 ++-- arch/arm/mm/mmu.c | 10 +++------- arch/arm/mm/nommu.c | 10 +++------- 3 files changed, 8 insertions(+), 16 deletions(-)
arch/arm/include/asm/pgtable.h +2 -2
@@ -15,8 +15,8 @@* ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE (vaddr) (empty_zero_page) +extern void *empty_zero_page; +#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page))#endif #include <asm-generic/pgtable-nopud.h>
arch/arm/mm/mmu.c +3 -7
@@ -45,7 +45,7 @@ extern unsigned long __atags_pointer;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +void *empty_zero_page;EXPORT_SYMBOL (empty_zero_page);/*
@@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -#ifdef CONFIG_XIP_KERNEL /* Store the kernel RW RAM region start/end in these variables */ kernel_sec_start =CONFIG_PHYS_OFFSET &SECTION_MASK ;
@@ -1782,12 +1780,10 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd =pmd_off_k (0xffff0000 );/* allocate the zero page. */ - zero_page =early_alloc (PAGE_SIZE ); + empty_zero_page =early_alloc (PAGE_SIZE ); +__cpuc_flush_dcache_area (empty_zero_page,PAGE_SIZE );bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -__flush_dcache_folio (NULL ,page_folio (empty_zero_page)); }void __init early_mm_init (const struct machine_desc *mdesc)
arch/arm/mm/nommu.c +3 -7
@@ -31,7 +31,7 @@ unsigned long vectors_base;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +void *empty_zero_page;EXPORT_SYMBOL (empty_zero_page);#ifdef CONFIG_ARM_MPU
@@ -156,18 +156,14 @@ void __init adjust_lowmem_bounds(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -early_trap_init ((void *)vectors_base);mpu_setup ();/* allocate the zero page. */ - zero_page = (void *)memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); + empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); +__cpuc_flush_dcache_area (empty_zero_page,PAGE_SIZE );bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -flush_dcache_page (empty_zero_page); }/*
Signature · 1 line
2.51.0
Quoted 3 lines
Regards,
Klara Modin
Signature · 2 lines
Sincerely yours, Mike.
Klara Modin
Tested-byRe: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
Hi,
Quoted 35 lines · Mike Rapoport
Hi,
Quoted 32 lines · Klara Modin
Quoted 31 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
To initialize node, zone and memory map data structures every architecture calls
free_area_init()duringsetup_arch()and passes it an array of zone limits.Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in
setup_arch()in certain cases, some only create hugetlb CMA areas insetup_arch()and sometimes hugetlb allocations happenmm_core_init().With
arch_zone_limits_init()helper available now on all architectures it is no longer necessary to callfree_area_init()from architecture setup code. Rather core MM initialization can callarch_zone_limits_init()in a single place.This allows to unify ordering of hugetlb vs memory map allocation and initialization.
Remove the call to
free_area_init()from architecture specific code and place it in a newmm_core_init_early()function that is called immediately aftersetup_arch().After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures.
As the first step of this consolidation move
hugetlb_bootmem_alloc()tomm_core_early_init().
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Mike Rapoport (Microsoft) <[email protected]>This breaks boot on my Raspberry Pi 1. The reason seems to be the use of
page_folio()when initializing the dynamically allocated zero page in arm, which doesn't work whenfree_area_init()hasn't been called yet.I believe the reason is rather the use of
virt_to_phys()that now happens before the memory map is ready.
Right, that makes sense, the fault just becomes apparent when page_folio() is called on some bogus address then?
Quoted 17 lines
Quoted 10 lines
The following oopses are generated:
8<--- cut here ---
Unable to handle kernel paging request at virtual address 003dfb44 when read [003dfb44] *pgd=00000000 Internal error: Oops: 5 [#1] ARM CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.19.0-rc3-03898-g7975b0084358 #451 NONE Hardware name: BCM2835 PC is at paging_init (include/linux/page-flags.h:284 (discriminator 2) arch/arm/mm/mmu.c:1790 (discriminator 2)) LR is at paging_init (arch/arm/mm/mmu.c:1789 (discriminator 1))...
Quoted 4 lines
8<--- cut here ---
and the second one repeats for some time afterwards.
Quoted 8 lines
Quoted 4 lines
I experimented a little by allocating the zero page statically as many other arches do which fixes the issue as it does not need to be initialized at this point anymore, though I have no idea if that's appropriate.
Do you mean putting the zero in the BSS like, e.g. arm64? I don't see a reason why this shouldn't work.
Yes, exactly that. The diff I had was:
arch/arm/include/asm/pgtable.h +2 -2
@@ -15,8 +15,8 @@* ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE (vaddr) (empty_zero_page) +extern unsigned long empty_zero_page[PAGE_SIZE /sizeof (unsigned long )]; +#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page))#endif #include <asm-generic/pgtable-nopud.h>
arch/arm/mm/mmu.c +1 -9
@@ -45,7 +45,7 @@ extern unsigned long __atags_pointer;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;EXPORT_SYMBOL (empty_zero_page);/*
@@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -#ifdef CONFIG_XIP_KERNEL /* Store the kernel RW RAM region start/end in these variables */ kernel_sec_start =CONFIG_PHYS_OFFSET &SECTION_MASK ;
@@ -1781,13 +1779,7 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd =pmd_off_k (0xffff0000 ); -/* allocate the zero page. */ - zero_page =early_alloc (PAGE_SIZE ); -bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -__flush_dcache_folio (NULL ,page_folio (empty_zero_page)); }void __init early_mm_init (const struct machine_desc *mdesc)
arch/arm/mm/nommu.c +1 -9
@@ -31,7 +31,7 @@ unsigned long vectors_base;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;EXPORT_SYMBOL (empty_zero_page);#ifdef CONFIG_ARM_MPU
@@ -156,18 +156,10 @@ void __init adjust_lowmem_bounds(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -early_trap_init ((void *)vectors_base);mpu_setup (); -/* allocate the zero page. */ - zero_page = (void *)memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); -bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -flush_dcache_page (empty_zero_page); }/*
Quoted 114 lines
I also have a patch with some minor changes that still keeps
empty_zero_pageallocated, but avoidsvirt_to_page()andfolio_page()dance. Can you please test it in your setup?From
8a213c13211106d592fbe96b68ee29879ed739f8Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (Microsoft)" <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory mapUnlike most architectures, arm keeps a struct page pointer to the
empty_zero_pageand to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating theempty_zero_page.Make
empty_zero_pagea void * to decouple it's initialization from the initialization of the memory map.Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- arch/arm/include/asm/pgtable.h | 4 ++-- arch/arm/mm/mmu.c | 10 +++------- arch/arm/mm/nommu.c | 10 +++------- 3 files changed, 8 insertions(+), 16 deletions(-)arch/arm/include/asm/pgtable.h +2
-2@@ -15,8 +15,8 @@* ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE (vaddr) (empty_zero_page) +extern void *empty_zero_page; +#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page))#endif #include <asm-generic/pgtable-nopud.h> arch/arm/mm/mmu.c +3
-7@@ -45,7 +45,7 @@ extern unsigned long __atags_pointer;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +void *empty_zero_page;EXPORT_SYMBOL (empty_zero_page);/* @@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -#ifdef CONFIG_XIP_KERNEL /* Store the kernel RW RAM region start/end in these variables */ kernel_sec_start =CONFIG_PHYS_OFFSET &SECTION_MASK ;@@ -1782,12 +1780,10 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd =pmd_off_k (0xffff0000 );/* allocate the zero page. */ - zero_page =early_alloc (PAGE_SIZE ); + empty_zero_page =early_alloc (PAGE_SIZE ); +__cpuc_flush_dcache_area (empty_zero_page,PAGE_SIZE );bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -__flush_dcache_folio (NULL ,page_folio (empty_zero_page)); }void __init early_mm_init (const struct machine_desc *mdesc)arch/arm/mm/nommu.c +3
-7@@ -31,7 +31,7 @@ unsigned long vectors_base;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +void *empty_zero_page;EXPORT_SYMBOL (empty_zero_page);#ifdef CONFIG_ARM_MPU @@ -156,18 +156,14 @@ void __init adjust_lowmem_bounds(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -early_trap_init ((void *)vectors_base);mpu_setup ();/* allocate the zero page. */ - zero_page = (void *)memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); + empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); +__cpuc_flush_dcache_area (empty_zero_page,PAGE_SIZE );bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -flush_dcache_page (empty_zero_page); }/* Signature · 1 line
2.51.0
This also works for me.
Thanks,
Quoted 8 lines
Quoted 4 lines
Regards,
Klara ModinSignature · 2 lines
Sincerely yours, Mike.
Mike Rapoport
maintainerPATCH 1/1 arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
Andrew,
Can you please stick this between patch 3 (arm: introduce arch_zone_limits_init()) and patch 4 (arm64: introduce arch_zone_limits_init())?
From 35d016bbf5da7c08cc5c5547c85558fc50cb63aa Mon Sep 17 00:00:00 2001
From: Klara Modin <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory map
Unlike most architectures, arm keeps a struct page pointer to the empty_zero_page and to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating the empty_zero_page.
Make empty_zero_page a stataic array in BSS to decouple it's initialization from the initialization of the memory map.
This also aligns arm with vast majorty of architectures.
--- arch/arm/include/asm/pgtable.h | 4 ++-- arch/arm/mm/mmu.c | 10 +--------- arch/arm/mm/nommu.c | 10 +--------- 3 files changed, 4 insertions(+), 20 deletions(-)
arch/arm/include/asm/pgtable.h +2 -2
@@ -15,8 +15,8 @@* ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. */ -extern struct page *empty_zero_page; -#define ZERO_PAGE (vaddr) (empty_zero_page) +extern unsigned long empty_zero_page[PAGE_SIZE /sizeof (unsigned long )]; +#define ZERO_PAGE (vaddr) (virt_to_page(empty_zero_page))#endif #include <asm-generic/pgtable-nopud.h>
arch/arm/mm/mmu.c +1 -9
@@ -45,7 +45,7 @@ extern unsigned long __atags_pointer;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;EXPORT_SYMBOL (empty_zero_page);/*
@@ -1754,8 +1754,6 @@ static void __init early_fixmap_shutdown(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -#ifdef CONFIG_XIP_KERNEL /* Store the kernel RW RAM region start/end in these variables */ kernel_sec_start =CONFIG_PHYS_OFFSET &SECTION_MASK ;
@@ -1781,13 +1779,7 @@ void __init paging_init(const struct machine_desc *mdesc) top_pmd =pmd_off_k (0xffff0000 ); -/* allocate the zero page. */ - zero_page =early_alloc (PAGE_SIZE ); -bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -__flush_dcache_folio (NULL ,page_folio (empty_zero_page)); }void __init early_mm_init (const struct machine_desc *mdesc)
arch/arm/mm/nommu.c +1 -9
@@ -31,7 +31,7 @@ unsigned long vectors_base;* empty_zero_page is a special page that is used for * zero-initialized data and COW. */ -struct page *empty_zero_page; +unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;EXPORT_SYMBOL (empty_zero_page);#ifdef CONFIG_ARM_MPU
@@ -156,18 +156,10 @@ void __init adjust_lowmem_bounds(void)*/ void __init paging_init (const struct machine_desc *mdesc) { -void *zero_page; -early_trap_init ((void *)vectors_base);mpu_setup (); -/* allocate the zero page. */ - zero_page = (void *)memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE ); -bootmem_init (); - - empty_zero_page =virt_to_page (zero_page); -flush_dcache_page (empty_zero_page); }/*
Signature · 1 line
2.51.0
Russell King (Oracle)
maintainerRe: [PATCH 3.5] arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
Quoted 6 lines · Mike Rapoport
From
35d016bbf5da7c08cc5c5547c85558fc50cb63aaMon Sep 17 00:00:00 2001
From: Klara Modin <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory map
Quoted 7 lines
Unlike most architectures, arm keeps a struct page pointer to the
empty_zero_pageand to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating theempty_zero_page.Make
empty_zero_pagea stataic array in BSS to decouple it's initialization from the initialization of the memory map.
I see you haven't considered _why_ ARM does this.
You are getting rid of the flush_dcache_page() call, which ensures that the zeroed contents of the page are pushed out of the cache into memory. This is necessary.
BSS is very similar. It's memset() during the kernel boot _after_ the caches are enabled. Without an explicit flush, nothing guarantees that those writes will be visible to userspace.
To me, this seems like a bad idea, which will cause userspace to break.
We need to call flush_dcache_page(), and _that_ requires a struct page.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Mike Rapoport
maintainerRe: [PATCH 3.5] arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
Quoted 17 lines · Russell King (Oracle)
Quoted 6 lines · Mike Rapoport
From
35d016bbf5da7c08cc5c5547c85558fc50cb63aaMon Sep 17 00:00:00 2001
From: Klara Modin <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory mapQuoted 7 lines
Unlike most architectures, arm keeps a struct page pointer to the
empty_zero_pageand to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating theempty_zero_page.Make
empty_zero_pagea stataic array in BSS to decouple it's initialization from the initialization of the memory map.I see you haven't considered _why_ ARM does this.
Quoted 7 lines
You are getting rid of the
flush_dcache_page()call, which ensures that the zeroed contents of the page are pushed out of the cache into memory. This is necessary.BSS is very similar. It's
memset()during the kernel boot _after_ the caches are enabled. Without an explicit flush, nothing guarantees that those writes will be visible to userspace.
There's a call to flush_cache_all() paging_init()->devicemaps_init() that will guarantee that those writes are flushed long before userspace starts.
Quoted 5 lines
To me, this seems like a bad idea, which will cause userspace to break.
We need to call
flush_dcache_page(), and _that_ requires a struct page.
Right now there's __flush_dcache_folio() that will break anyway when folio divorces from struct page.
Signature · 2 lines
Sincerely yours, Mike.
Ritesh Harjani (IBM)
reviewerRe: [PATCH v2 14/28] powerpc: introduce arch_zone_limits_init()
In reply to Mike RapoportQuoted 19 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated
arch_zone_limits_init()function.Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call
free_area_init()from every architecture.Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- arch/powerpc/mm/mem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)arch/powerpc/mm/mem.c +0
-0
arch/powerpc/mm/mem.c static int __init mark_nonram_nosave(void) · line 227
Quoted 8 lines
arch/powerpc/mm/mem.c +4
-1@@ -221,13 +221,23 @@ static int __init mark_nonram_nosave(void)* anyway) will take a first dip into ZONE_NORMAL and get otherwise served by * ZONE_DMA. */ -static unsigned long max_zone_pfns[MAX_NR_ZONES ]; +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA ] =min (zone_dma_limit, max_low_pfn -1 ) +1 ;
Hi Mike,
This doesn't look correct. Isn't the zone_dma_limit value in bytes actually? Shouldn't it be -
max_zone_pfns[ZONE_DMA] = min((zone_dma_limit >> PAGE_SHIFT) + 1, max_low_pfn);
-ritesh
Quoted 35 lines
arch/powerpc/mm/mem.c +8
-9+#endif + max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; +#ifdef CONFIG_HIGHMEM + max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; +#endif +}/* * paging_init() sets up the page tables - in fact we've already done this. */ void __init paging_init (void ) { +unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long long total_ram =memblock_phys_mem_size ();phys_addr_t top_of_ram =memblock_end_of_DRAM ();int zone_dma_bits;@@ -259,15 +269,7 @@ void __init paging_init(void) zone_dma_limit =DMA_BIT_MASK (zone_dma_bits); -#ifdef CONFIG_ZONE_DMA - max_zone_pfns[ZONE_DMA ] =min (max_low_pfn, -1UL << (zone_dma_bits -PAGE_SHIFT )); -#endif - max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; -#ifdef CONFIG_HIGHMEM - max_zone_pfns[ZONE_HIGHMEM ] = max_pfn; -#endif - +arch_zone_limits_init (max_zone_pfns);free_area_init (max_zone_pfns);mark_nonram_nosave ();Signature · 1 line
2.51.0
Mike Rapoport
maintainerRe: [PATCH v2 14/28] powerpc: introduce arch_zone_limits_init()
Hi,
Quoted 32 lines · Ritesh Harjani
Quoted 19 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated
arch_zone_limits_init()function.Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call
free_area_init()from every architecture.Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- arch/powerpc/mm/mem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)arch/powerpc/mm/mem.c +0
-0arch/powerpc/mm/mem.c static int __init mark_nonram_nosave(void) · line 227
Quoted 8 lines
arch/powerpc/mm/mem.c +4
-1@@ -221,13 +221,23 @@ static int __init mark_nonram_nosave(void)* anyway) will take a first dip into ZONE_NORMAL and get otherwise served by * ZONE_DMA. */ -static unsigned long max_zone_pfns[MAX_NR_ZONES ]; +void __init arch_zone_limits_init (unsigned long *max_zone_pfns) +{ +#ifdef CONFIG_ZONE_DMA + max_zone_pfns[ZONE_DMA ] =min (zone_dma_limit, max_low_pfn -1 ) +1 ;Hi Mike,
Quoted 4 lines
This doesn't look correct. Isn't the
zone_dma_limitvalue in bytes actually? Shouldn't it be -max_zone_pfns[ZONE_DMA] = min((zone_dma_limit >> PAGE_SHIFT) + 1, max_low_pfn);
You are right, I'll update it for v3.
Quoted 1 line
-ritesh
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 02/28] arc: introduce arch_zone_limits_init()
In reply to Mike RapoportQuoted 10 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Move calculations of zone limits to a dedicated
arch_zone_limits_init()function.Later MM core will use this function as an architecture specific callback during nodes and zones initialization and thus there won't be a need to call
free_area_init()from every architecture.Signed-off-by Mike Rapoport (Microsoft) <[email protected]>
Thx !
Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
In reply to Mike RapoportQuoted 815 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
To initialize node, zone and memory map data structures every architecture calls
free_area_init()duringsetup_arch()and passes it an array of zone limits.Beside code duplication it creates "interesting" ordering cases between allocation and initialization of hugetlb and the memory map. Some architectures allocate hugetlb pages very early in
setup_arch()in certain cases, some only create hugetlb CMA areas insetup_arch()and sometimes hugetlb allocations happenmm_core_init().With
arch_zone_limits_init()helper available now on all architectures it is no longer necessary to callfree_area_init()from architecture setup code. Rather core MM initialization can callarch_zone_limits_init()in a single place.This allows to unify ordering of hugetlb vs memory map allocation and initialization.
Remove the call to
free_area_init()from architecture specific code and place it in a newmm_core_init_early()function that is called immediately aftersetup_arch().After this refactoring it is possible to consolidate hugetlb allocations and eliminate differences in ordering of hugetlb and memory map initialization among different architectures.
As the first step of this consolidation move
hugetlb_bootmem_alloc()tomm_core_early_init().Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- arch/alpha/mm/init.c | 9 +-------- arch/arc/mm/init.c | 5 ----- arch/arm/mm/init.c | 16 ---------------- arch/arm64/mm/init.c | 4 ---- arch/csky/kernel/setup.c | 4 ---- arch/hexagon/mm/init.c | 12 ------------ arch/loongarch/include/asm/pgtable.h | 2 -- arch/loongarch/kernel/setup.c | 2 -- arch/loongarch/mm/init.c | 8 -------- arch/m68k/mm/init.c | 3 --- arch/m68k/mm/mcfmmu.c | 3 --- arch/m68k/mm/motorola.c | 6 +----- arch/m68k/mm/sun3mmu.c | 9 --------- arch/microblaze/mm/init.c | 7 ------- arch/mips/loongson64/numa.c | 4 ---- arch/mips/mm/init.c | 5 ----- arch/mips/sgi-ip27/ip27-memory.c | 4 ---- arch/nios2/mm/init.c | 6 ------ arch/openrisc/mm/init.c | 10 ---------- arch/parisc/mm/init.c | 9 --------- arch/powerpc/mm/mem.c | 4 ---- arch/riscv/mm/init.c | 9 --------- arch/s390/mm/init.c | 5 ----- arch/sh/mm/init.c | 5 ----- arch/sparc/mm/init_64.c | 11 ----------- arch/sparc/mm/srmmu.c | 7 ------- arch/um/kernel/mem.c | 5 ----- arch/x86/mm/init.c | 10 ---------- arch/x86/mm/init_32.c | 1 - arch/x86/mm/init_64.c | 2 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 4 ---- include/linux/mm.h | 4 ++-- init/main.c | 1 + mm/mm_init.c | 18 ++++++++++-------- 35 files changed, 15 insertions(+), 200 deletions(-)arch/alpha/mm/init.c +1
-8@@ -220,17 +220,10 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn) }/* -* paging_init() sets up the memory map. +* paging_init() initializes the kernel's ZERO_PGE. */ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -/* Initialize mem_map[]. */ -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); - -/* Initialize the kernel's ZERO_PGE. */ memset (absolute_pointer (ZERO_PGE ),0 ,PAGE_SIZE ); }arch/arc/mm/init.c +0
-5@@ -102,8 +102,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn)*/ void __init setup_arch_memory (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -setup_initial_init_mm (_text, _etext, _edata, _end);/* first page of system - kernel .vector starts here */ @@ -158,9 +156,6 @@ void __init setup_arch_memory(void) arch_pfn_offset =min (min_low_pfn, min_high_pfn);kmap_init ();#endif /* CONFIG_HIGHMEM */ - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }void __init arch_mm_preinit (void )arch/arm/mm/init.c +0
-16@@ -118,15 +118,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfn)#endif } -static void __init zone_sizes_init (unsigned long min,unsigned long max_low, -unsigned long max_high) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -#ifdef CONFIG_HAVE_ARCH_PFN_VALID int pfn_valid (unsigned long pfn) {@@ -222,13 +213,6 @@ void __init bootmem_init(void)* done after the fixed reservations */ sparse_init (); - -/* -* Now free the memory - free_area_init needs -* the sparse mem_map arrays initialized by sparse_init() -* for memmap_init_zone(), otherwise all PFNs are invalid. -*/ -zone_sizes_init (min_low_pfn, max_low_pfn, max_pfn); }/* arch/arm64/mm/init.c +0
-4@@ -134,7 +134,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)static void __init dma_limits_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 };phys_addr_t __maybe_unused acpi_zone_dma_limit;phys_addr_t __maybe_unused dt_zone_dma_limit; phys_addr_t __maybe_unused dma32_phys_limit =@@ -160,9 +159,6 @@ static void __init dma_limits_init(void)#endif if (!arm64_dma_phys_limit) arm64_dma_phys_limit =PHYS_MASK +1 ; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }int pfn_is_map_memory (unsigned long pfn)arch/csky/kernel/setup.c +0
-4@@ -63,7 +63,6 @@ static void __init csky_memblock_init(void) {unsigned long lowmem_size =PFN_DOWN (LOWMEM_LIMIT -PHYS_OFFSET_OFFSET );unsigned long sseg_size =PFN_DOWN (SSEG_SIZE -PHYS_OFFSET_OFFSET ); -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };signed long size;memblock_reserve (__pa (_start), _end - _start);@@ -101,9 +100,6 @@ static void __init csky_memblock_init(void)memblock_set_current_limit (PFN_PHYS (max_low_pfn));dma_contiguous_reserve (0 ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }void __init setup_arch (char **cmdline_p)arch/hexagon/mm/init.c +0
-12@@ -66,20 +66,8 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -/* -* In order to set up page allocator "nodes", -* somebody has to call free_area_init() for UMA. -* -* In this mode, we only have one pg_data_t -* structure: contig_mem_data. -*/ static void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn);/* sets up the zonelists and mem_map */ -/* * Set the init_mm descriptors "context" value to point to the * initial kernel segment table's physical address. arch/loongarch/include/asm/pgtable.h +0
-2@@ -353,8 +353,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)return pte; } -extern void paging_init (void ); -#define pte_none (pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))#define pte_present (pte) (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE))#define pte_no_exec (pte) (pte_val(pte) & _PAGE_NO_EXEC)arch/loongarch/kernel/setup.c +0
-2@@ -621,8 +621,6 @@ void __init setup_arch(char **cmdline_p)prefill_possible_map ();#endif -paging_init (); -#ifdef CONFIG_KASAN kasan_init ();#endif arch/loongarch/mm/init.c +0
-8@@ -68,14 +68,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -void __init paging_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -void __ref free_initmem (void ) {free_initmem_default (POISON_FREE_INITMEM );arch/m68k/mm/init.c +0
-3@@ -69,13 +69,10 @@ void __init paging_init(void)* page_alloc get different views of the world. */ unsigned long end_mem = memory_end &PAGE_MASK ; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; high_memory = (void *) end_mem; empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); -arch_zone_limits_init (max_zone_pfn); - free_area_init(max_zone_pfn); }#endif /* CONFIG_MMU */ arch/m68k/mm/mcfmmu.c +0
-3@@ -39,7 +39,6 @@ void __init paging_init(void)pte_t *pg_table;unsigned long address, size;unsigned long next_pgtable; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };int i; empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE );@@ -73,8 +72,6 @@ void __init paging_init(void) } current->mm =NULL ; -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }int cf_tlb_miss (struct pt_regs *regs,int write,int dtlb,int extension_word)arch/m68k/mm/motorola.c +1
-5@@ -429,7 +429,6 @@ DECLARE_VM_GET_PAGE_PROT*/ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };unsigned long min_addr, max_addr;unsigned long addr;int i;@@ -511,12 +510,9 @@ void __init paging_init(void)set_fc (USER_DATA );#ifdef DEBUG -printk ("before free_area_init\n" ); +printk ("before node_set_state\n" );#endif for (i =0 ; i < m68k_num_memory; i++)if (node_present_pages (i))node_set_state (i,N_NORMAL_MEMORY ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }arch/m68k/mm/sun3mmu.c +0
-9@@ -41,7 +41,6 @@ void __init paging_init(void)unsigned long address;unsigned long next_pgtable;unsigned long bootmem_end; -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , };unsigned long size; empty_zero_page =memblock_alloc_or_panic (PAGE_SIZE ,PAGE_SIZE );@@ -80,14 +79,6 @@ void __init paging_init(void)mmu_emu_init (bootmem_end); current->mm =NULL ; - -/* memory sizing is a hack stolen from motorola.c.. hope it works for us */ -arch_zone_limits_init (max_zone_pfn); - -/* I really wish I knew why the following change made things better... -- Sam */ -free_area_init (max_zone_pfn); - - }static const pgprot_t protection_map[16 ] = {arch/microblaze/mm/init.c +0
-7@@ -69,22 +69,15 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ static void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ];int idx;/* Setup fixmaps */ for (idx =0 ; idx < __end_of_fixed_addresses; idx++)clear_fixmap (idx); -/* Clean every zones */ -memset (zones_size,0 ,sizeof (zones_size)); -#ifdef CONFIG_HIGHMEM highmem_init ();#endif -arch_zone_limits_init (zones_size); -/* We don't have holes in memory map */ -free_area_init (zones_size); }void __init setup_memory (void )arch/mips/loongson64/numa.c +0
-4@@ -162,11 +162,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 , }; -pagetable_init (); -arch_zone_limits_init (zones_size); -free_area_init (zones_size); }/* All PCI device belongs to logical Node-0 */ arch/mips/mm/init.c +0
-5@@ -417,12 +417,7 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; -pagetable_init (); - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }#ifdef CONFIG_64BIT arch/mips/sgi-ip27/ip27-memory.c +0
-4@@ -413,9 +413,5 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 , }; -pagetable_init (); -arch_zone_limits_init (zones_size); -free_area_init (zones_size); }arch/nios2/mm/init.c +0
-6@@ -51,15 +51,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; -pagetable_init (); pgd_current = swapper_pg_dir; -arch_zone_limits_init (max_zone_pfn); -/* pass the memory from the bootmem allocator to the main allocator */ -free_area_init (max_zone_pfn); -flush_dcache_range ((unsigned long )empty_zero_page, (unsigned long )empty_zero_page +PAGE_SIZE ); }arch/openrisc/mm/init.c +0
-10@@ -47,14 +47,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -static void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -extern const char _s_kernel_ro[], _e_kernel_ro[];/* @@ -145,8 +137,6 @@ void __init paging_init(void)map_ram (); -zone_sizes_init (); -/* self modifying code ;) */ /* Since the old TLB miss handler has been running up until now, * the kernel pages are still all RW, so we can still modify the arch/parisc/mm/init.c +0
-9@@ -698,14 +698,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] =PFN_DOWN (memblock_end_of_DRAM ()); } -static void __init parisc_bootmem_free (void ) -{ -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); -} -void __init paging_init (void ) {setup_bootmem ();@@ -716,7 +708,6 @@ void __init paging_init(void)flush_tlb_all_local (NULL );sparse_init (); -parisc_bootmem_free (); } static void alloc_btlb(unsigned long start, unsigned long end, int *slot,arch/powerpc/mm/mem.c +0
-4@@ -237,7 +237,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long long total_ram =memblock_phys_mem_size ();phys_addr_t top_of_ram =memblock_end_of_DRAM ();int zone_dma_bits;@@ -269,9 +268,6 @@ void __init paging_init(void) zone_dma_limit =DMA_BIT_MASK (zone_dma_bits); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -mark_nonram_nosave (); }arch/riscv/mm/init.c +0
-9@@ -87,14 +87,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns) max_zone_pfns[ZONE_NORMAL ] = max_low_pfn; } -static void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -#if defined(CONFIG_MMU ) && defined(CONFIG_DEBUG_VM )#define LOG2_SZ_1K ilog2(SZ_1K)@@ -1443,7 +1435,6 @@ void __init misc_mem_init(void)/* The entire VMEMMAP region has been populated. Flush TLB for this region */ local_flush_tlb_kernel_range (VMEMMAP_START ,VMEMMAP_END );#endif -zone_sizes_init ();arch_reserve_crashkernel ();memblock_dump_all (); }arch/s390/mm/init.c +0
-5@@ -97,14 +97,9 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)*/ void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; -vmem_map_init ();sparse_init (); zone_dma_limit =DMA_BIT_MASK (31 ); -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }void mark_rodata_ro (void )arch/sh/mm/init.c +0
-5@@ -271,7 +271,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfns[MAX_NR_ZONES ];unsigned long vaddr, end; sh_mv.mv_mem_init ();@@ -325,10 +324,6 @@ void __init paging_init(void)page_table_range_init (vaddr, end, swapper_pg_dir);kmap_coherent_init (); - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); }unsigned int mem_init_done =0 ;arch/sparc/mm/init_64.c +0
-11@@ -2459,17 +2459,6 @@ void __init paging_init(void)kernel_physical_mapping_init (); - { -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - - max_zone_pfns[ZONE_NORMAL ] = end_pfn; - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); - } -printk ("Booting Linux...\n" ); }arch/sparc/mm/srmmu.c +0
-7@@ -970,13 +970,6 @@ void __init srmmu_paging_init(void)flush_tlb_all ();sparc_context_init (num_contexts); - - { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); - } }void mmu_info (struct seq_file *m)arch/um/kernel/mem.c +0
-5@@ -91,16 +91,11 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init paging_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 }; - empty_zero_page = (unsigned long *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE );if (!empty_zero_page)panic ("%s: Failed to allocate %lu bytes align=%lx\n" , __func__,PAGE_SIZE ,PAGE_SIZE ); - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn); }/* arch/x86/mm/init.c +0
-10@@ -1011,16 +1011,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)#endif } -void __init zone_sizes_init (void ) -{ -unsigned long max_zone_pfns[MAX_NR_ZONES ]; - -memset (max_zone_pfns,0 ,sizeof (max_zone_pfns)); - -arch_zone_limits_init (max_zone_pfns); -free_area_init (max_zone_pfns); -} -__visible DEFINE_PER_CPU_ALIGNED (struct tlb_state ,cpu_tlbstate ) = { .loaded_mm = &init_mm, .next_asid =1 ,arch/x86/mm/init_32.c +0
-1@@ -655,7 +655,6 @@ void __init paging_init(void)*/ olpc_dt_build_devicetree ();sparse_init (); -zone_sizes_init (); }/* arch/x86/mm/init_64.c +0
-2@@ -843,8 +843,6 @@ void __init paging_init(void)*/ node_clear_state (0 ,N_MEMORY );node_clear_state (0 ,N_NORMAL_MEMORY ); - -zone_sizes_init (); }#define PAGE_UNUSED 0xFDarch/x86/mm/mm_internal.h +0
-1@@ -17,7 +17,6 @@ unsigned long kernel_physical_mapping_init(unsigned long start,unsigned long kernel_physical_mapping_change (unsigned long start,unsigned long end,unsigned long page_size_mask); -void zone_sizes_init (void );extern int after_bootmem;arch/xtensa/mm/init.c +0
-4@@ -126,10 +126,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)void __init zones_init (void ) { -unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 , }; - -arch_zone_limits_init (max_zone_pfn); -free_area_init (max_zone_pfn);print_vm_layout (); }include/linux/mm.h +2
-2@@ -45,6 +45,7 @@ struct pt_regs;struct folio_batch ;void arch_mm_preinit (void ); +void mm_core_init_early (void );void mm_core_init (void );void init_mm_internals (void );@@ -3536,7 +3537,7 @@ static inline unsigned long get_num_physpages(void) }/* -* Using memblock node mappings, an architecture may initialise its +* FIXME: Using memblock node mappings, an architecture may initialise its * zones, allocate the backing mem_map and account for memory holes in an * architecture independent manner. * @@ -3551,7 +3552,6 @@ static inline unsigned long get_num_physpages(void)* memblock_add_node(base, size, nid, MEMBLOCK_NONE) * free_area_init(max_zone_pfns); */ -void free_area_init (unsigned long *max_zone_pfn);void arch_zone_limits_init (unsigned long *max_zone_pfn);unsigned long node_map_pfn_alignment (void ); extern unsigned long absent_pages_in_range(unsigned long start_pfn,init/main.c +1
-0@@ -1025,6 +1025,7 @@ void start_kernel(void)page_address_init ();pr_notice ("%s" , linux_banner);setup_arch (&command_line); +mm_core_init_early ();/* Static keys and static calls are needed by LSMs */ jump_label_init ();static_call_init ();mm/mm_init.c +10
-7@@ -1810,7 +1810,6 @@ static void __init set_high_memory(void)/** * free_area_init - Initialise all pg_data_t and zone data -* @max_zone_pfn: an array of max PFNs for each zone * * This will call free_area_init_node() for each active node in the system. * Using the page ranges provided by memblock_set_node(), the size of each @@ -1821,17 +1820,14 @@ static void __init set_high_memory(void)* starts where the previous one ended. For example, ZONE_DMA32 starts * at arch_max_dma_pfn. */ -void __init free_area_init (unsigned long *max_zone_pfn) +static void __init free_area_init (void ) { +unsigned long max_zone_pfn[MAX_NR_ZONES ] = {0 };unsigned long start_pfn, end_pfn;int i, nid, zone;bool descending; -/* Record where the zone boundaries are */ -memset (arch_zone_lowest_possible_pfn,0 , -sizeof (arch_zone_lowest_possible_pfn)); -memset (arch_zone_highest_possible_pfn,0 , -sizeof (arch_zone_highest_possible_pfn)); +arch_zone_limits_init (max_zone_pfn); start_pfn =PHYS_PFN (memblock_start_of_DRAM ()); descending =arch_has_descending_max_zone_pfns ();@@ -2681,13 +2677,19 @@ void __init __weak mem_init(void) { } +void __init mm_core_init_early (void ) +{ +hugetlb_bootmem_alloc (); + +free_area_init (); +} +
mm/mm_init.c void __init __weak mem_init(void) · line 2695
Quoted 10 lines
mm/mm_init.c +0
-1/* * Set up kernel memory allocators */ void __init mm_core_init (void ) {arch_mm_preinit (); -hugetlb_bootmem_alloc ();/* Initializations relying on SMP setup */ BUILD_BUG_ON (MAX_ZONELISTS >2 );
Hello,
This patch got bisected to cause BeagleBone Black boot failure in linux-next version next-20260107.
At the moment I cannot provide any helpful information about this.
BR
Kalle
Mike Rapoport
maintainerRe: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
Hi,
Quoted 7 lines · Kalle Niemi
Quoted 2 lines · Mike Rapoport
From: "Mike Rapoport (Microsoft)" <[email protected]>
Hello,
This patch got bisected to cause BeagleBone Black boot failure in linux-next version next-20260107.
Can you check if this patch fixes it?
https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
At the moment I cannot provide any helpful information about this.
BR
Kalle
Signature · 2 lines
Sincerely yours, Mike.
Andrew Morton
maintainerRe: [PATCH 3.5] arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
In reply to Mike RapoportQuoted 3 lines · On Sun, 4 Jan 2026 14:01:40 +0200 Mike Rapoport <[email protected]> wrote:
Can you please stick this between patch 3 (arm: introduce
arch_zone_limits_init()) and patch 4 (arm64: introducearch_zone_limits_init())?
Did, thanks. I made this a standalone patch rather than a squashable -fix.
Quoted 11 lines
Quoted 1 line
From
35d016bbf5da7c08cc5c5547c85558fc50cb63aaMon Sep 17 00:00:00 2001From: Klara Modin <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory mapUnlike most architectures, arm keeps a struct page pointer to the
empty_zero_pageand to initialize it requires conversion of a virtual address to page which makes it necessary to have memory map initialized before creating theempty_zero_page.
Quoted 4 lines
Make
empty_zero_pagea stataic array in BSS to decouple it's initialization from the initialization of the memory map.This also aligns arm with vast majorty of architectures.
Russell, can you please update us on your concerns with this change?
Re: [PATCH 3.5] arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
In reply to Mike RapoportThis patch was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes)
by Andrew Morton <[email protected]>:
Quoted 6 lines · On Sun, 4 Jan 2026 14:01:40 +0200 you wrote:
Andrew,
Can you please stick this between patch 3 (arm: introduce
arch_zone_limits_init()) and patch 4 (arm64: introducearch_zone_limits_init())?
Quoted 7 lines
From
35d016bbf5da7c08cc5c5547c85558fc50cb63aaMon Sep 17 00:00:00 2001
From: Klara Modin <[email protected]>
Date: Sat, 3 Jan 2026 20:40:09 +0200
Subject: [PATCH] arm: make initialization of zero page independent of the
memory map[...]
Here is the summary with links:
- [3.5] arm: make initialization of zero page independent of the memory map (was Re: [PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map)
https://git.kernel.org/riscv/c/18b7cc70dea8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html