The point where the memory is released from memblock to the buddy
allocator is hidden inside arch-specific mem_init()s and the call to
memblock_free_all() is needlessly duplicated in every artiste cure and
after introduction of arch_mm_preinit() hook, mem_init() implementation on
many architecture only contains the call to memblock_free_all().
Pull memblock_free_all() call into mm_core_init() and drop mem_init() on
relevant architectures to make it more explicit where the free memory is
released from memblock to the buddy allocator and to reduce code
duplication in architecture specific code.
Link: https://lkml.kernel.org/r/20250313135003.836600-14-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com> [x86]
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Tested-by: Mark Brown <broonie@kernel.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Betkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Guo Ren (csky) <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: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russel King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
}
#endif
-void __init
-mem_init(void)
-{
- memblock_free_all();
-}
-
static const pgprot_t protection_map[16] = {
[VM_NONE] = _PAGE_P(_PAGE_FOE | _PAGE_FOW |
_PAGE_FOR),
BUILD_BUG_ON((PTRS_PER_PTE * sizeof(pte_t)) > PAGE_SIZE);
}
-/*
- * mem_init - initializes memory
- *
- * Frees up bootmem
- * Calculates and displays memory available/used
- */
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
#ifdef CONFIG_HIGHMEM
int pfn_valid(unsigned long pfn)
{
#endif
}
-/*
- * mem_init() marks the free areas in the mem_map and tells us how much
- * memory is free. This is done after various parts of the system have
- * claimed their memory after the kernel image.
- */
-void __init mem_init(void)
-{
- /* this will put all unused low memory onto the freelists */
- memblock_free_all();
-}
-
#ifdef CONFIG_STRICT_KERNEL_RWX
struct section_perm {
const char *name;
}
}
-/*
- * mem_init() marks the free areas in the mem_map and tells us how much memory
- * is free. This is done after various parts of the system have claimed their
- * memory after the kernel image.
- */
-void __init mem_init(void)
-{
- /* this will put all unused low memory onto the freelists */
- memblock_free_all();
-}
-
void free_initmem(void)
{
void *lm_init_begin = lm_alias(__init_begin);
__page_aligned_bss;
EXPORT_SYMBOL(empty_zero_page);
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
void free_initmem(void)
{
free_initmem_default(-1);
/* checkpatch says don't init this to 0. */
unsigned long long kmap_generation;
-/*
- * mem_init - initializes memory
- *
- * Frees up bootmem
- * Fixes up more stuff for HIGHMEM
- * Calculates and displays memory available/used
- */
-void __init mem_init(void)
-{
- /* No idea where this is actually declared. Seems to evade LXR. */
- memblock_free_all();
-
- /*
- * To-Do: someone somewhere should wipe out the bootmem map
- * after we're done?
- */
-}
-
void sync_icache_dcache(pte_t pte)
{
unsigned long addr;
free_area_init(zones_size);
}
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
int pcibus_to_node(struct pci_bus *bus)
{
return dev_to_node(&bus->dev);
free_area_init(max_zone_pfns);
}
-
-void __init mem_init(void)
-{
- memblock_free_all();
-}
#endif /* !CONFIG_NUMA */
void __ref free_initmem(void)
void __init mem_init(void)
{
- /* this will put all memory onto the freelists */
- memblock_free_all();
init_pointer_tables();
}
void __init mem_init(void)
{
- /* this will put all memory onto the freelists */
- memblock_free_all();
-
mem_init_done = 1;
}
}
#endif /* !CONFIG_NUMA */
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
void free_init_pages(const char *what, unsigned long begin, unsigned long end)
{
unsigned long pfn;
(unsigned long)empty_zero_page + PAGE_SIZE);
}
-void __init mem_init(void)
-{
- /* this will put all memory onto the freelists */
- memblock_free_all();
-}
-
void __init mmu_init(void)
{
flush_tlb_all();
/* clear the zero-page */
memset((void *)empty_zero_page, 0, PAGE_SIZE);
- /* this will put all low memory onto the freelists */
- memblock_free_all();
-
printk("mem_init_done ...........................................\n");
mem_init_done = 1;
return;
BUILD_BUG_ON(TMPALIAS_MAP_START >= 0x80000000);
#endif
- memblock_free_all();
-
#ifdef CONFIG_PA11
if (boot_cpu_data.cpu_type == pcxl2 || boot_cpu_data.cpu_type == pcxl) {
pcxl_dma_start = (unsigned long)SET_MAP_OFFSET(MAP_START);
#endif /* CONFIG_PPC32 */
}
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
void free_initmem(void)
{
ppc_md.progress = ppc_printk_progress;
print_vm_layout();
}
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
/* Limit the memory size via mem. */
static phys_addr_t memory_limit;
#ifdef CONFIG_XIP_KERNEL
setup_zero_pages(); /* Setup zeroed pages. */
}
-void __init mem_init(void)
-{
- /* this will put all low memory onto the freelists */
- memblock_free_all();
-}
-
unsigned long memory_block_size_bytes(void)
{
/*
void __init mem_init(void)
{
- memblock_free_all();
-
/* Set this up early, so we can take care of the zero page */
cpu_cache_init();
taint_real_pages();
}
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
void sparc_flush_page_to_ram(struct page *page)
{
unsigned long vaddr = (unsigned long)page_address(page);
}
void __init mem_init(void)
{
- memblock_free_all();
-
/*
* Must be done after boot memory is put on freelist, because here we
* might set fields in deferred struct pages that have not yet been
void __init mem_init(void)
{
- /* this will put all low memory onto the freelists */
- memblock_free_all();
kmalloc_ok = 1;
}
void __init mem_init(void)
{
- /* this will put all low memory onto the freelists */
- memblock_free_all();
-
after_bootmem = 1;
x86_init.hyper.init_after_bootmem();
{
/* clear_bss() already clear the empty_zero_page */
- /* this will put all memory onto the freelists */
- memblock_free_all();
after_bootmem = 1;
x86_init.hyper.init_after_bootmem();
print_vm_layout();
}
-/*
- * Initialize memory pages.
- */
-
-void __init mem_init(void)
-{
- memblock_free_all();
-}
-
static void __init parse_memmap_one(char *p)
{
char *oldp;
int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
int memblock_reserved_mark_noinit(phys_addr_t base, phys_addr_t size);
-void memblock_free_all(void);
void memblock_free(void *ptr, size_t size);
void reset_all_zones_managed_pages(void);
}
extern bool mirrored_kernelcore;
-extern bool memblock_has_mirror(void);
+bool memblock_has_mirror(void);
+void memblock_free_all(void);
static __always_inline void vma_set_range(struct vm_area_struct *vma,
unsigned long start, unsigned long end,
{
}
+void __init __weak mem_init(void)
+{
+}
+
/*
* Set up kernel memory allocators
*/
report_meminit();
kmsan_init_shadow();
stack_depot_early_init();
+ memblock_free_all();
mem_init();
kmem_cache_init();
/*