[PATCH] mm: remove unneeded __meminit annotation

From: Miaohe Lin
Date: Mon Aug 07 2023 - 21:59:01 EST


kswapd_stop() and kcompactd_stop() are only called when MEMORY_HOTREMOVE
is enabled. So wrap them under CONFIG_MEMORY_HOTREMOVE and further remove
__meminit annotation. No functional change intended.

Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
---
include/linux/compaction.h | 2 +-
include/linux/swap.h | 2 +-
mm/compaction.c | 4 +++-
mm/vmscan.c | 4 +++-
4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index e94776496049..3dbb7eea96eb 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -99,7 +99,7 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
int alloc_flags);

extern void __meminit kcompactd_run(int nid);
-extern void __meminit kcompactd_stop(int nid);
+extern void kcompactd_stop(int nid);
extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx);

#else
diff --git a/include/linux/swap.h b/include/linux/swap.h
index bb5adc604144..c102587b3a86 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -437,7 +437,7 @@ static inline bool node_reclaim_enabled(void)
void check_move_unevictable_folios(struct folio_batch *fbatch);

extern void __meminit kswapd_run(int nid);
-extern void __meminit kswapd_stop(int nid);
+extern void kswapd_stop(int nid);

#ifdef CONFIG_SWAP

diff --git a/mm/compaction.c b/mm/compaction.c
index ea61922a1619..c59244d2ed5a 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -3132,11 +3132,12 @@ void __meminit kcompactd_run(int nid)
}
}

+#ifdef CONFIG_MEMORY_HOTREMOVE
/*
* Called by memory hotplug when all memory in a node is offlined. Caller must
* be holding mem_hotplug_begin/done().
*/
-void __meminit kcompactd_stop(int nid)
+void kcompactd_stop(int nid)
{
struct task_struct *kcompactd = NODE_DATA(nid)->kcompactd;

@@ -3145,6 +3146,7 @@ void __meminit kcompactd_stop(int nid)
NODE_DATA(nid)->kcompactd = NULL;
}
}
+#endif

/*
* It's optimal to keep kcompactd on the same CPUs as their memory, but
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 80e9a222e522..eb4db273bf7e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7897,11 +7897,12 @@ void __meminit kswapd_run(int nid)
pgdat_kswapd_unlock(pgdat);
}

+#ifdef CONFIG_MEMORY_HOTREMOVE
/*
* Called by memory hotplug when all memory in a node is offlined. Caller must
* be holding mem_hotplug_begin/done().
*/
-void __meminit kswapd_stop(int nid)
+void kswapd_stop(int nid)
{
pg_data_t *pgdat = NODE_DATA(nid);
struct task_struct *kswapd;
@@ -7914,6 +7915,7 @@ void __meminit kswapd_stop(int nid)
}
pgdat_kswapd_unlock(pgdat);
}
+#endif

static int __init kswapd_init(void)
{
--
2.33.0