mm: make some vars and functions static or __init
authorTing Liu <liuting.0x7c00@bytedance.com>
Fri, 14 Jan 2022 22:09:28 +0000 (14:09 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Jan 2022 14:30:31 +0000 (16:30 +0200)
"page_idle_ops" as a global var, but its scope of use within this
document.  So it should be static.

"page_ext_ops" is a var used in the kernel initial phase.  And other
functions are aslo used in the kernel initial phase.  So they should be
__init or __initdata to reclaim memory.

Link: https://lkml.kernel.org/r/20211217095023.67293-1-liuting.0x7c00@bytedance.com
Signed-off-by: Ting Liu <liuting.0x7c00@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/page_idle.h
mm/page_ext.c
mm/page_owner.c

index 83abf95e9fa7ddb7f55708bc612ac6cef5d0cdf6..4663dfed12931a59210cb429f6851f811b66064f 100644 (file)
@@ -13,7 +13,6 @@
  * If there is not enough space to store Idle and Young bits in page flags, use
  * page ext flags instead.
  */
-extern struct page_ext_operations page_idle_ops;
 
 static inline bool folio_test_young(struct folio *folio)
 {
index bee3240604dcb1ef7486667b14127c04c8434189..2e66d934d63f2f25fce2c6a5c32d67e3c58d8608 100644 (file)
@@ -64,12 +64,12 @@ static bool need_page_idle(void)
 {
        return true;
 }
-struct page_ext_operations page_idle_ops = {
+static struct page_ext_operations page_idle_ops __initdata = {
        .need = need_page_idle,
 };
 #endif
 
-static struct page_ext_operations *page_ext_ops[] = {
+static struct page_ext_operations *page_ext_ops[] __initdata = {
 #ifdef CONFIG_PAGE_OWNER
        &page_owner_ops,
 #endif
index 4f924957ce7a09e0fa0f4d68ea2a3aecd3495a69..5eea061bb1e5994361debbd7deca28a170b4bcd6 100644 (file)
@@ -46,7 +46,7 @@ static int __init early_page_owner_param(char *buf)
 }
 early_param("page_owner", early_page_owner_param);
 
-static bool need_page_owner(void)
+static __init bool need_page_owner(void)
 {
        return page_owner_enabled;
 }
@@ -75,7 +75,7 @@ static noinline void register_early_stack(void)
        early_handle = create_dummy_stack();
 }
 
-static void init_page_owner(void)
+static __init void init_page_owner(void)
 {
        if (!page_owner_enabled)
                return;