From 8d228fbbce34bcb79d2ece6b828b628bd9b80d7c 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 e01df4271585..00e8988e5a84 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -44,8 +44,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) { } @@ -69,6 +73,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 7942ad3cdb42..ed884e3dfb3b 100644 --- a/init/main.c +++ b/init/main.c @@ -541,6 +541,8 @@ static void __init mm_init(void) page_ext_init_flatmem(); report_meminit(); mem_init(); + /* page_owner must be initialized after buddy is ready */ + page_ext_init_flatmem_late(); kmem_cache_init(); pgtable_init(); vmalloc_init(); diff --git a/mm/page_ext.c b/mm/page_ext.c index aad120123688..9e7f56e45b5a 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -102,6 +102,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 unsigned long get_entry_size(void) { return sizeof(struct page_ext) + extra_mem; @@ -185,7 +192,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: