From 7f35a1228f2d872474ac10ffd669bd604d3d7275 Mon Sep 17 00:00:00 2001 From: Zhenhua Huang Date: Mon, 31 Aug 2020 00:20:35 +0800 Subject: [PATCH] mm: fix the page_owner initializing issue for arm32 arm32 original logic: 1. allocated memory for page_ext(using memblock). 2. invoke the init callback of page_ext_ops like page_owner(using buddy). 3. initialize buddy. after this change: 1. allocated memory for page_ext(using memblock). 2. initialize buddy. 3. invoke the init callback of page_ext_ops like page_owner(using buddy). with the change, failure/dummy_handle can get its correct value. Change-Id: I6598481299da115ff4be50bf0e5a61a012d5ac83 Signed-off-by: Zhenhua Huang --- include/linux/page_ext.h | 8 ++++++++ init/main.c | 2 ++ mm/page_ext.c | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h index e50acd1810c9..8fec316fb6c8 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -47,8 +47,12 @@ static inline void page_ext_init_flatmem(void) { } extern void page_ext_init(void); +static inline void page_ext_init_flatmem_late(void) +{ +} #else extern void page_ext_init_flatmem(void); +extern void page_ext_init_flatmem_late(void); static inline void page_ext_init(void) { } @@ -79,6 +83,10 @@ static inline void page_ext_init(void) { } +static inline void page_ext_init_flatmem_late(void) +{ +} + static inline void page_ext_init_flatmem(void) { } diff --git a/init/main.c b/init/main.c index 9e0e160bbe24..60ec1a7b35c9 100644 --- a/init/main.c +++ b/init/main.c @@ -558,6 +558,8 @@ static void __init mm_init(void) init_debug_pagealloc(); report_meminit(); mem_init(); + /* page_owner must be initialized after buddy is ready */ + page_ext_init_flatmem_late(); kmem_cache_init(); kmemleak_init(); pgtable_init(); diff --git a/mm/page_ext.c b/mm/page_ext.c index 4ade843ff588..5c5282d9065f 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -99,6 +99,13 @@ static void __init invoke_init_callbacks(void) } } +#if !defined(CONFIG_SPARSEMEM) +void __init page_ext_init_flatmem_late(void) +{ + invoke_init_callbacks(); +} +#endif + static inline struct page_ext *get_entry(void *base, unsigned long index) { return base + page_ext_size * index; @@ -177,7 +184,6 @@ void __init page_ext_init_flatmem(void) goto fail; } pr_info("allocated %ld bytes of page_ext\n", total_usage); - invoke_init_callbacks(); return; fail: