Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arch, mm: consolidate initialization of nodes, zones and memory map

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().

Link: https://lkml.kernel.org/r/20260111082105.290734-24-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alex Shi <alexs@kernel.org>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Klara Modin <klarasmodin@gmail.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Magnus Lindholm <linmag7@gmail.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mike Rapoport (Microsoft) and committed by
Andrew Morton
d49004c5 2d3c8c5f

+15 -200
+1 -8
arch/alpha/mm/init.c
··· 220 220 } 221 221 222 222 /* 223 - * paging_init() sets up the memory map. 223 + * paging_init() initializes the kernel's ZERO_PGE. 224 224 */ 225 225 void __init paging_init(void) 226 226 { 227 - unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; 228 - 229 - /* Initialize mem_map[]. */ 230 - arch_zone_limits_init(max_zone_pfn); 231 - free_area_init(max_zone_pfn); 232 - 233 - /* Initialize the kernel's ZERO_PGE. */ 234 227 memset(absolute_pointer(ZERO_PGE), 0, PAGE_SIZE); 235 228 } 236 229
-5
arch/arc/mm/init.c
··· 102 102 */ 103 103 void __init setup_arch_memory(void) 104 104 { 105 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 106 - 107 105 setup_initial_init_mm(_text, _etext, _edata, _end); 108 106 109 107 /* first page of system - kernel .vector starts here */ ··· 156 158 arch_pfn_offset = min(min_low_pfn, min_high_pfn); 157 159 kmap_init(); 158 160 #endif /* CONFIG_HIGHMEM */ 159 - 160 - arch_zone_limits_init(max_zone_pfn); 161 - free_area_init(max_zone_pfn); 162 161 } 163 162 164 163 void __init arch_mm_preinit(void)
-16
arch/arm/mm/init.c
··· 118 118 #endif 119 119 } 120 120 121 - static void __init zone_sizes_init(unsigned long min, unsigned long max_low, 122 - unsigned long max_high) 123 - { 124 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 125 - 126 - arch_zone_limits_init(max_zone_pfn); 127 - free_area_init(max_zone_pfn); 128 - } 129 - 130 121 #ifdef CONFIG_HAVE_ARCH_PFN_VALID 131 122 int pfn_valid(unsigned long pfn) 132 123 { ··· 213 222 * done after the fixed reservations 214 223 */ 215 224 sparse_init(); 216 - 217 - /* 218 - * Now free the memory - free_area_init needs 219 - * the sparse mem_map arrays initialized by sparse_init() 220 - * for memmap_init_zone(), otherwise all PFNs are invalid. 221 - */ 222 - zone_sizes_init(min_low_pfn, max_low_pfn, max_pfn); 223 225 } 224 226 225 227 /*
-4
arch/arm64/mm/init.c
··· 134 134 135 135 static void __init dma_limits_init(void) 136 136 { 137 - unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; 138 137 phys_addr_t __maybe_unused acpi_zone_dma_limit; 139 138 phys_addr_t __maybe_unused dt_zone_dma_limit; 140 139 phys_addr_t __maybe_unused dma32_phys_limit = ··· 159 160 #endif 160 161 if (!arm64_dma_phys_limit) 161 162 arm64_dma_phys_limit = PHYS_MASK + 1; 162 - 163 - arch_zone_limits_init(max_zone_pfns); 164 - free_area_init(max_zone_pfns); 165 163 } 166 164 167 165 int pfn_is_map_memory(unsigned long pfn)
-4
arch/csky/kernel/setup.c
··· 63 63 { 64 64 unsigned long lowmem_size = PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET); 65 65 unsigned long sseg_size = PFN_DOWN(SSEG_SIZE - PHYS_OFFSET_OFFSET); 66 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 67 66 signed long size; 68 67 69 68 memblock_reserve(__pa(_start), _end - _start); ··· 100 101 memblock_set_current_limit(PFN_PHYS(max_low_pfn)); 101 102 102 103 dma_contiguous_reserve(0); 103 - 104 - arch_zone_limits_init(max_zone_pfn); 105 - free_area_init(max_zone_pfn); 106 104 } 107 105 108 106 void __init setup_arch(char **cmdline_p)
-12
arch/hexagon/mm/init.c
··· 66 66 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 67 67 } 68 68 69 - /* 70 - * In order to set up page allocator "nodes", 71 - * somebody has to call free_area_init() for UMA. 72 - * 73 - * In this mode, we only have one pg_data_t 74 - * structure: contig_mem_data. 75 - */ 76 69 static void __init paging_init(void) 77 70 { 78 - unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; 79 - 80 - arch_zone_limits_init(max_zone_pfn); 81 - free_area_init(max_zone_pfn); /* sets up the zonelists and mem_map */ 82 - 83 71 /* 84 72 * Set the init_mm descriptors "context" value to point to the 85 73 * initial kernel segment table's physical address.
-2
arch/loongarch/include/asm/pgtable.h
··· 353 353 return pte; 354 354 } 355 355 356 - extern void paging_init(void); 357 - 358 356 #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL)) 359 357 #define pte_present(pte) (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 360 358 #define pte_no_exec(pte) (pte_val(pte) & _PAGE_NO_EXEC)
-2
arch/loongarch/kernel/setup.c
··· 621 621 prefill_possible_map(); 622 622 #endif 623 623 624 - paging_init(); 625 - 626 624 #ifdef CONFIG_KASAN 627 625 kasan_init(); 628 626 #endif
-8
arch/loongarch/mm/init.c
··· 68 68 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 69 69 } 70 70 71 - void __init paging_init(void) 72 - { 73 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 74 - 75 - arch_zone_limits_init(max_zone_pfns); 76 - free_area_init(max_zone_pfns); 77 - } 78 - 79 71 void __ref free_initmem(void) 80 72 { 81 73 free_initmem_default(POISON_FREE_INITMEM);
-3
arch/m68k/mm/init.c
··· 69 69 * page_alloc get different views of the world. 70 70 */ 71 71 unsigned long end_mem = memory_end & PAGE_MASK; 72 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; 73 72 74 73 high_memory = (void *) end_mem; 75 74 76 75 empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); 77 - arch_zone_limits_init(max_zone_pfn); 78 - free_area_init(max_zone_pfn); 79 76 } 80 77 81 78 #endif /* CONFIG_MMU */
-3
arch/m68k/mm/mcfmmu.c
··· 39 39 pte_t *pg_table; 40 40 unsigned long address, size; 41 41 unsigned long next_pgtable; 42 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 43 42 int i; 44 43 45 44 empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); ··· 72 73 } 73 74 74 75 current->mm = NULL; 75 - arch_zone_limits_init(max_zone_pfn); 76 - free_area_init(max_zone_pfn); 77 76 } 78 77 79 78 int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
+1 -5
arch/m68k/mm/motorola.c
··· 429 429 */ 430 430 void __init paging_init(void) 431 431 { 432 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; 433 432 unsigned long min_addr, max_addr; 434 433 unsigned long addr; 435 434 int i; ··· 510 511 set_fc(USER_DATA); 511 512 512 513 #ifdef DEBUG 513 - printk ("before free_area_init\n"); 514 + printk ("before node_set_state\n"); 514 515 #endif 515 516 for (i = 0; i < m68k_num_memory; i++) 516 517 if (node_present_pages(i)) 517 518 node_set_state(i, N_NORMAL_MEMORY); 518 - 519 - arch_zone_limits_init(max_zone_pfn); 520 - free_area_init(max_zone_pfn); 521 519 }
-9
arch/m68k/mm/sun3mmu.c
··· 41 41 unsigned long address; 42 42 unsigned long next_pgtable; 43 43 unsigned long bootmem_end; 44 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; 45 44 unsigned long size; 46 45 47 46 empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); ··· 79 80 mmu_emu_init(bootmem_end); 80 81 81 82 current->mm = NULL; 82 - 83 - /* memory sizing is a hack stolen from motorola.c.. hope it works for us */ 84 - arch_zone_limits_init(max_zone_pfn); 85 - 86 - /* I really wish I knew why the following change made things better... -- Sam */ 87 - free_area_init(max_zone_pfn); 88 - 89 - 90 83 } 91 84 92 85 static const pgprot_t protection_map[16] = {
-7
arch/microblaze/mm/init.c
··· 69 69 */ 70 70 static void __init paging_init(void) 71 71 { 72 - unsigned long zones_size[MAX_NR_ZONES]; 73 72 int idx; 74 73 75 74 /* Setup fixmaps */ 76 75 for (idx = 0; idx < __end_of_fixed_addresses; idx++) 77 76 clear_fixmap(idx); 78 77 79 - /* Clean every zones */ 80 - memset(zones_size, 0, sizeof(zones_size)); 81 - 82 78 #ifdef CONFIG_HIGHMEM 83 79 highmem_init(); 84 80 #endif 85 - arch_zone_limits_init(zones_size); 86 - /* We don't have holes in memory map */ 87 - free_area_init(zones_size); 88 81 } 89 82 90 83 void __init setup_memory(void)
-4
arch/mips/loongson64/numa.c
··· 162 162 163 163 void __init paging_init(void) 164 164 { 165 - unsigned long zones_size[MAX_NR_ZONES] = {0, }; 166 - 167 165 pagetable_init(); 168 - arch_zone_limits_init(zones_size); 169 - free_area_init(zones_size); 170 166 } 171 167 172 168 /* All PCI device belongs to logical Node-0 */
-5
arch/mips/mm/init.c
··· 417 417 418 418 void __init paging_init(void) 419 419 { 420 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 421 - 422 420 pagetable_init(); 423 - 424 - arch_zone_limits_init(max_zone_pfns); 425 - free_area_init(max_zone_pfns); 426 421 } 427 422 428 423 #ifdef CONFIG_64BIT
-4
arch/mips/sgi-ip27/ip27-memory.c
··· 413 413 414 414 void __init paging_init(void) 415 415 { 416 - unsigned long zones_size[MAX_NR_ZONES] = {0, }; 417 - 418 416 pagetable_init(); 419 - arch_zone_limits_init(zones_size); 420 - free_area_init(zones_size); 421 417 }
-6
arch/nios2/mm/init.c
··· 51 51 */ 52 52 void __init paging_init(void) 53 53 { 54 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 55 - 56 54 pagetable_init(); 57 55 pgd_current = swapper_pg_dir; 58 - 59 - arch_zone_limits_init(max_zone_pfn); 60 - /* pass the memory from the bootmem allocator to the main allocator */ 61 - free_area_init(max_zone_pfn); 62 56 63 57 flush_dcache_range((unsigned long)empty_zero_page, 64 58 (unsigned long)empty_zero_page + PAGE_SIZE);
-10
arch/openrisc/mm/init.c
··· 47 47 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 48 48 } 49 49 50 - static void __init zone_sizes_init(void) 51 - { 52 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 53 - 54 - arch_zone_limits_init(max_zone_pfn); 55 - free_area_init(max_zone_pfn); 56 - } 57 - 58 50 extern const char _s_kernel_ro[], _e_kernel_ro[]; 59 51 60 52 /* ··· 136 144 current_pgd[smp_processor_id()] = init_mm.pgd; 137 145 138 146 map_ram(); 139 - 140 - zone_sizes_init(); 141 147 142 148 /* self modifying code ;) */ 143 149 /* Since the old TLB miss handler has been running up until now,
-9
arch/parisc/mm/init.c
··· 698 698 max_zone_pfns[ZONE_NORMAL] = PFN_DOWN(memblock_end_of_DRAM()); 699 699 } 700 700 701 - static void __init parisc_bootmem_free(void) 702 - { 703 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; 704 - 705 - arch_zone_limits_init(max_zone_pfn); 706 - free_area_init(max_zone_pfn); 707 - } 708 - 709 701 void __init paging_init(void) 710 702 { 711 703 setup_bootmem(); ··· 708 716 flush_tlb_all_local(NULL); 709 717 710 718 sparse_init(); 711 - parisc_bootmem_free(); 712 719 } 713 720 714 721 static void alloc_btlb(unsigned long start, unsigned long end, int *slot,
-4
arch/powerpc/mm/mem.c
··· 237 237 */ 238 238 void __init paging_init(void) 239 239 { 240 - unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0 }; 241 240 unsigned long long total_ram = memblock_phys_mem_size(); 242 241 phys_addr_t top_of_ram = memblock_end_of_DRAM(); 243 242 int zone_dma_bits; ··· 267 268 zone_dma_bits = 31; 268 269 269 270 zone_dma_limit = DMA_BIT_MASK(zone_dma_bits); 270 - 271 - arch_zone_limits_init(max_zone_pfns); 272 - free_area_init(max_zone_pfns); 273 271 274 272 mark_nonram_nosave(); 275 273 }
-9
arch/riscv/mm/init.c
··· 87 87 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 88 88 } 89 89 90 - static void __init zone_sizes_init(void) 91 - { 92 - unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; 93 - 94 - arch_zone_limits_init(max_zone_pfns); 95 - free_area_init(max_zone_pfns); 96 - } 97 - 98 90 #if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM) 99 91 100 92 #define LOG2_SZ_1K ilog2(SZ_1K) ··· 1435 1443 /* The entire VMEMMAP region has been populated. Flush TLB for this region */ 1436 1444 local_flush_tlb_kernel_range(VMEMMAP_START, VMEMMAP_END); 1437 1445 #endif 1438 - zone_sizes_init(); 1439 1446 arch_reserve_crashkernel(); 1440 1447 memblock_dump_all(); 1441 1448 }
-5
arch/s390/mm/init.c
··· 97 97 */ 98 98 void __init paging_init(void) 99 99 { 100 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 101 - 102 100 vmem_map_init(); 103 101 sparse_init(); 104 102 zone_dma_limit = DMA_BIT_MASK(31); 105 - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 106 - arch_zone_limits_init(max_zone_pfns); 107 - free_area_init(max_zone_pfns); 108 103 } 109 104 110 105 void mark_rodata_ro(void)
-5
arch/sh/mm/init.c
··· 271 271 272 272 void __init paging_init(void) 273 273 { 274 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 275 274 unsigned long vaddr, end; 276 275 277 276 sh_mv.mv_mem_init(); ··· 324 325 page_table_range_init(vaddr, end, swapper_pg_dir); 325 326 326 327 kmap_coherent_init(); 327 - 328 - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 329 - arch_zone_limits_init(max_zone_pfns); 330 - free_area_init(max_zone_pfns); 331 328 } 332 329 333 330 unsigned int mem_init_done = 0;
-11
arch/sparc/mm/init_64.c
··· 2459 2459 2460 2460 kernel_physical_mapping_init(); 2461 2461 2462 - { 2463 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 2464 - 2465 - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 2466 - 2467 - max_zone_pfns[ZONE_NORMAL] = end_pfn; 2468 - 2469 - arch_zone_limits_init(max_zone_pfns); 2470 - free_area_init(max_zone_pfns); 2471 - } 2472 - 2473 2462 printk("Booting Linux...\n"); 2474 2463 } 2475 2464
-7
arch/sparc/mm/srmmu.c
··· 970 970 flush_tlb_all(); 971 971 972 972 sparc_context_init(num_contexts); 973 - 974 - { 975 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 976 - 977 - arch_zone_limits_init(max_zone_pfn); 978 - free_area_init(max_zone_pfn); 979 - } 980 973 } 981 974 982 975 void mmu_info(struct seq_file *m)
-5
arch/um/kernel/mem.c
··· 91 91 92 92 void __init paging_init(void) 93 93 { 94 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 95 - 96 94 empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE, 97 95 PAGE_SIZE); 98 96 if (!empty_zero_page) 99 97 panic("%s: Failed to allocate %lu bytes align=%lx\n", 100 98 __func__, PAGE_SIZE, PAGE_SIZE); 101 - 102 - arch_zone_limits_init(max_zone_pfn); 103 - free_area_init(max_zone_pfn); 104 99 } 105 100 106 101 /*
-10
arch/x86/mm/init.c
··· 1011 1011 #endif 1012 1012 } 1013 1013 1014 - void __init zone_sizes_init(void) 1015 - { 1016 - unsigned long max_zone_pfns[MAX_NR_ZONES]; 1017 - 1018 - memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 1019 - 1020 - arch_zone_limits_init(max_zone_pfns); 1021 - free_area_init(max_zone_pfns); 1022 - } 1023 - 1024 1014 __visible DEFINE_PER_CPU_ALIGNED(struct tlb_state, cpu_tlbstate) = { 1025 1015 .loaded_mm = &init_mm, 1026 1016 .next_asid = 1,
-1
arch/x86/mm/init_32.c
··· 655 655 */ 656 656 olpc_dt_build_devicetree(); 657 657 sparse_init(); 658 - zone_sizes_init(); 659 658 } 660 659 661 660 /*
-2
arch/x86/mm/init_64.c
··· 843 843 */ 844 844 node_clear_state(0, N_MEMORY); 845 845 node_clear_state(0, N_NORMAL_MEMORY); 846 - 847 - zone_sizes_init(); 848 846 } 849 847 850 848 #define PAGE_UNUSED 0xFD
-1
arch/x86/mm/mm_internal.h
··· 17 17 unsigned long kernel_physical_mapping_change(unsigned long start, 18 18 unsigned long end, 19 19 unsigned long page_size_mask); 20 - void zone_sizes_init(void); 21 20 22 21 extern int after_bootmem; 23 22
-4
arch/xtensa/mm/init.c
··· 126 126 127 127 void __init zones_init(void) 128 128 { 129 - unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, }; 130 - 131 - arch_zone_limits_init(max_zone_pfn); 132 - free_area_init(max_zone_pfn); 133 129 print_vm_layout(); 134 130 } 135 131
+2 -2
include/linux/mm.h
··· 45 45 struct folio_batch; 46 46 47 47 void arch_mm_preinit(void); 48 + void mm_core_init_early(void); 48 49 void mm_core_init(void); 49 50 void init_mm_internals(void); 50 51 ··· 3541 3540 } 3542 3541 3543 3542 /* 3544 - * Using memblock node mappings, an architecture may initialise its 3543 + * FIXME: Using memblock node mappings, an architecture may initialise its 3545 3544 * zones, allocate the backing mem_map and account for memory holes in an 3546 3545 * architecture independent manner. 3547 3546 * ··· 3556 3555 * memblock_add_node(base, size, nid, MEMBLOCK_NONE) 3557 3556 * free_area_init(max_zone_pfns); 3558 3557 */ 3559 - void free_area_init(unsigned long *max_zone_pfn); 3560 3558 void arch_zone_limits_init(unsigned long *max_zone_pfn); 3561 3559 unsigned long node_map_pfn_alignment(void); 3562 3560 extern unsigned long absent_pages_in_range(unsigned long start_pfn,
+1
init/main.c
··· 1025 1025 page_address_init(); 1026 1026 pr_notice("%s", linux_banner); 1027 1027 setup_arch(&command_line); 1028 + mm_core_init_early(); 1028 1029 /* Static keys and static calls are needed by LSMs */ 1029 1030 jump_label_init(); 1030 1031 static_call_init();
+10 -8
mm/mm_init.c
··· 1807 1807 1808 1808 /** 1809 1809 * free_area_init - Initialise all pg_data_t and zone data 1810 - * @max_zone_pfn: an array of max PFNs for each zone 1811 1810 * 1812 1811 * This will call free_area_init_node() for each active node in the system. 1813 1812 * Using the page ranges provided by memblock_set_node(), the size of each ··· 1817 1818 * starts where the previous one ended. For example, ZONE_DMA32 starts 1818 1819 * at arch_max_dma_pfn. 1819 1820 */ 1820 - void __init free_area_init(unsigned long *max_zone_pfn) 1821 + static void __init free_area_init(void) 1821 1822 { 1823 + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; 1822 1824 unsigned long start_pfn, end_pfn; 1823 1825 int i, nid, zone; 1824 1826 bool descending; 1825 1827 1826 - /* Record where the zone boundaries are */ 1827 - memset(arch_zone_lowest_possible_pfn, 0, 1828 - sizeof(arch_zone_lowest_possible_pfn)); 1829 - memset(arch_zone_highest_possible_pfn, 0, 1830 - sizeof(arch_zone_highest_possible_pfn)); 1828 + arch_zone_limits_init(max_zone_pfn); 1831 1829 1832 1830 start_pfn = PHYS_PFN(memblock_start_of_DRAM()); 1833 1831 descending = arch_has_descending_max_zone_pfns(); ··· 2674 2678 { 2675 2679 } 2676 2680 2681 + void __init mm_core_init_early(void) 2682 + { 2683 + hugetlb_bootmem_alloc(); 2684 + 2685 + free_area_init(); 2686 + } 2687 + 2677 2688 /* 2678 2689 * Set up kernel memory allocators 2679 2690 */ 2680 2691 void __init mm_core_init(void) 2681 2692 { 2682 2693 arch_mm_preinit(); 2683 - hugetlb_bootmem_alloc(); 2684 2694 2685 2695 /* Initializations relying on SMP setup */ 2686 2696 BUILD_BUG_ON(MAX_ZONELISTS > 2);