* [PATCH] mm: make some vars and functions static or __init
@ 2021-12-15 5:26 Ting Liu
2021-12-16 8:59 ` Muchun Song
0 siblings, 1 reply; 3+ messages in thread
From: Ting Liu @ 2021-12-15 5:26 UTC (permalink / raw)
To: akpm
Cc: linux-mm, linux-kernel, vbabka, shakeelb, willy, sjpark, liuting.0x7c00
From: "liuting.0x7c00" <liuting.0x7c00@bytedance.com>
"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.
Signed-off-by: liuting.0x7c00 <liuting.0x7c00@bytedance.com>
---
include/linux/page_idle.h | 1 -
mm/page_ext.c | 4 ++--
mm/page_owner.c | 4 ++--
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h
index 83abf95e9fa7..4663dfed1293 100644
--- a/include/linux/page_idle.h
+++ b/include/linux/page_idle.h
@@ -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)
{
diff --git a/mm/page_ext.c b/mm/page_ext.c
index 6242afb24d84..2193e3f10e56 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -63,12 +63,12 @@ static bool need_page_idle(void)
{
return true;
}
-struct page_ext_operations page_idle_ops = {
+static struct page_ext_operations page_idle_ops = {
.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
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 4f924957ce7a..5eea061bb1e5 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -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;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: make some vars and functions static or __init
2021-12-15 5:26 [PATCH] mm: make some vars and functions static or __init Ting Liu
@ 2021-12-16 8:59 ` Muchun Song
0 siblings, 0 replies; 3+ messages in thread
From: Muchun Song @ 2021-12-16 8:59 UTC (permalink / raw)
To: Ting Liu
Cc: Andrew Morton, Linux Memory Management List, LKML,
Vlastimil Babka, Shakeel Butt, Matthew Wilcox, sjpark
On Wed, Dec 15, 2021 at 1:27 PM Ting Liu <liuting.0x7c00@bytedance.com> wrote:
>
> From: "liuting.0x7c00" <liuting.0x7c00@bytedance.com>
>
> "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.
>
> Signed-off-by: liuting.0x7c00 <liuting.0x7c00@bytedance.com>
> ---
> include/linux/page_idle.h | 1 -
> mm/page_ext.c | 4 ++--
> mm/page_owner.c | 4 ++--
> 3 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h
> index 83abf95e9fa7..4663dfed1293 100644
> --- a/include/linux/page_idle.h
> +++ b/include/linux/page_idle.h
> @@ -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)
> {
> diff --git a/mm/page_ext.c b/mm/page_ext.c
> index 6242afb24d84..2193e3f10e56 100644
> --- a/mm/page_ext.c
> +++ b/mm/page_ext.c
> @@ -63,12 +63,12 @@ static bool need_page_idle(void)
Should need_page_idle be marked as __init?
It is used in the initialization stage.
> {
> return true;
> }
> -struct page_ext_operations page_idle_ops = {
> +static struct page_ext_operations page_idle_ops = {
> .need = need_page_idle,
> };
page_idle_ops is also used in the initialization stage.
It also can be marked as __initdata.
> #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
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 4f924957ce7a..5eea061bb1e5 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -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;
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] mm: make some vars and functions static or __init
@ 2021-12-17 9:50 Ting Liu
0 siblings, 0 replies; 3+ messages in thread
From: Ting Liu @ 2021-12-17 9:50 UTC (permalink / raw)
To: akpm
Cc: linux-mm, linux-kernel, vbabka, shakeelb, willy, sjpark, liuting.0x7c00
From: "liuting.0x7c00" <liuting.0x7c00@bytedance.com>
"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.
Signed-off-by: liuting.0x7c00 <liuting.0x7c00@bytedance.com>
Signed-off-by: Ting Liu <liuting.0x7c00@bytedance.com>
---
include/linux/page_idle.h | 1 -
mm/page_ext.c | 4 ++--
mm/page_owner.c | 4 ++--
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h
index 83abf95e9fa7..4663dfed1293 100644
--- a/include/linux/page_idle.h
+++ b/include/linux/page_idle.h
@@ -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)
{
diff --git a/mm/page_ext.c b/mm/page_ext.c
index 6242afb24d84..eecd7221143d 100644
--- a/mm/page_ext.c
+++ b/mm/page_ext.c
@@ -63,12 +63,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
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 4f924957ce7a..5eea061bb1e5 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -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;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-17 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 5:26 [PATCH] mm: make some vars and functions static or __init Ting Liu
2021-12-16 8:59 ` Muchun Song
2021-12-17 9:50 Ting Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).