Message ID | 20250306185124.3147510-6-rppt@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | arch, mm: reduce code duplication in mem_init() | expand |
On Thu, Mar 06, 2025 at 08:51:15PM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> > > Allocating the zero pages from memblock is simpler because the memory is > already reserved. > > This will also help with pulling out memblock_free_all() to the generic > code and reducing code duplication in arch::mem_init(). > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > --- > arch/mips/include/asm/mmzone.h | 2 -- > arch/mips/mm/init.c | 16 +++++----------- > 2 files changed, 5 insertions(+), 13 deletions(-) Andrew can you please pick this as a fixup? From 148713d17cbdf7a3ad08f18ba203185b70c0e7c2 Mon Sep 17 00:00:00 2001 From: "Mike Rapoport (Microsoft)" <rppt@kernel.org> Date: Tue, 11 Mar 2025 07:51:27 +0200 Subject: [PATCH] MIPS: use memblock_alloc_or_panic() in setup_zero_page() Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> --- arch/mips/mm/init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 6ea27bbd387e..a673d3d68254 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -68,9 +68,7 @@ static void __init setup_zero_pages(void) else order = 0; - empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE << order, PAGE_SIZE); - if (!empty_zero_page) - panic("Oh boy, that early out of memory?"); + empty_zero_page = (unsigned long)memblock_alloc_or_panic(PAGE_SIZE << order, PAGE_SIZE); zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK; }
diff --git a/arch/mips/include/asm/mmzone.h b/arch/mips/include/asm/mmzone.h index 14226ea42036..602a21aee9d4 100644 --- a/arch/mips/include/asm/mmzone.h +++ b/arch/mips/include/asm/mmzone.h @@ -20,6 +20,4 @@ #define nid_to_addrbase(nid) 0 #endif -extern void setup_zero_pages(void); - #endif /* _ASM_MMZONE_H_ */ diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 3db6082c611e..f51cd97376df 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -59,25 +59,19 @@ EXPORT_SYMBOL(zero_page_mask); /* * Not static inline because used by IP27 special magic initialization code */ -void setup_zero_pages(void) +static void __init setup_zero_pages(void) { - unsigned int order, i; - struct page *page; + unsigned int order; if (cpu_has_vce) order = 3; else order = 0; - empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order); + empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE << order, PAGE_SIZE); if (!empty_zero_page) panic("Oh boy, that early out of memory?"); - page = virt_to_page((void *)empty_zero_page); - split_page(page, order); - for (i = 0; i < (1 << order); i++, page++) - mark_page_reserved(page); - zero_page_mask = ((PAGE_SIZE << order) - 1) & PAGE_MASK; } @@ -470,9 +464,9 @@ void __init mem_init(void) BUILD_BUG_ON(IS_ENABLED(CONFIG_32BIT) && (PFN_PTE_SHIFT > PAGE_SHIFT)); maar_init(); - memblock_free_all(); setup_zero_pages(); /* Setup zeroed pages. */ mem_init_free_highmem(); + memblock_free_all(); #ifdef CONFIG_64BIT if ((unsigned long) &_text > (unsigned long) CKSEG0) @@ -486,8 +480,8 @@ void __init mem_init(void) void __init mem_init(void) { high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); - memblock_free_all(); setup_zero_pages(); /* This comes from node 0 */ + memblock_free_all(); } #endif /* !CONFIG_NUMA */