lkml.org 
[lkml]   [2022]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC] page_ext: move up page_ext_init() to catch early page allocation if DEFERRED_STRUCT_PAGE_INIT is n
Date
From: Li Zhe <lizhe.67@bytedance.com>

In 'commit 2f1ee0913ce5 ("Revert "mm: use early_pfn_to_nid in page_ext_init"")',
we call page_ext_init() after page_alloc_init_late() to avoid some panic
problem. It seems that we cannot track early page allocations in current
kernel even if page structure has been initialized early.

This patch move up page_ext_init() to catch early page allocations when
DEFERRED_STRUCT_PAGE_INIT is n. After this patch, we only need to turn
DEFERRED_STRUCT_PAGE_INIT to n then we are able to analyze the early page
allocations. This is useful especially when we find that the free memory
value is not the same right after different kernel booting.

Signed-off-by: Li Zhe <lizhe.67@bytedance.com>
---
include/linux/page_ext.h | 28 ++++++++++++++++++++++++++--
init/main.c | 7 +++++--
mm/page_ext.c | 2 +-
3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h
index fabb2e1e087f..82ebca63779c 100644
--- a/include/linux/page_ext.h
+++ b/include/linux/page_ext.h
@@ -43,14 +43,34 @@ extern void pgdat_page_ext_init(struct pglist_data *pgdat);
static inline void page_ext_init_flatmem(void)
{
}
-extern void page_ext_init(void);
static inline void page_ext_init_flatmem_late(void)
{
}
+extern void _page_ext_init(void);
+#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
+static inline void page_ext_init_early(void)
+{
+}
+static inline void page_ext_init_late(void)
+{
+ _page_ext_init();
+}
+#else
+static inline void page_ext_init_early(void)
+{
+ _page_ext_init();
+}
+static inline void page_ext_init_late(void)
+{
+}
+#endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
#else
extern void page_ext_init_flatmem(void);
extern void page_ext_init_flatmem_late(void);
-static inline void page_ext_init(void)
+static inline void page_ext_init_early(void)
+{
+}
+static inline void page_ext_init_late(void)
{
}
#endif
@@ -80,6 +100,10 @@ static inline void page_ext_init(void)
{
}

+static inline void page_ext_init_late(void)
+{
+}
+
static inline void page_ext_init_flatmem_late(void)
{
}
diff --git a/init/main.c b/init/main.c
index 91642a4e69be..7f9533ba527d 100644
--- a/init/main.c
+++ b/init/main.c
@@ -845,6 +845,7 @@ static void __init mm_init(void)
* slab is ready so that stack_depot_init() works properly
*/
page_ext_init_flatmem_late();
+ page_ext_init_early();
kmemleak_init();
pgtable_init();
debug_objects_mem_init();
@@ -1605,8 +1606,10 @@ static noinline void __init kernel_init_freeable(void)

padata_init();
page_alloc_init_late();
- /* Initialize page ext after all struct pages are initialized. */
- page_ext_init();
+ /* Initialize page ext after all struct pages are initialized if
+ * CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled
+ */
+ page_ext_init_late();

do_basic_setup();

diff --git a/mm/page_ext.c b/mm/page_ext.c
index 3dc715d7ac29..50419e7349cb 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -378,7 +378,7 @@ static int __meminit page_ext_callback(struct notifier_block *self,
return notifier_from_errno(ret);
}

-void __init page_ext_init(void)
+void __init _page_ext_init(void)
{
unsigned long pfn;
int nid;
--
2.20.1
\
 
 \ /
  Last update: 2022-08-04 08:56    [W:0.023 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site