[PATCH] mm: split out memory-failure declarations from internal.h
From: Breno Leitao
Date: Wed Nov 04 2026 - 11:58:25 EST
mm/internal.h carries the memory failure declarations, but only seven
of the 81 .c files that include it use them.
Move memory failure declarations to a new mm/memory-failure.h and
include that from those seven files that need them.
Move the block as is, including take_page_off_buddy(),
put_page_back_buddy() and page_mapped_in_vma(): they live in
page_alloc.c and page_vma_mapped.c, but are built only for
CONFIG_MEMORY_FAILURE and called only from memory-failure.c.
Keep the declarations private to mm/.
No functional change.
Suggested-by: Mike Rapoport <rppt@xxxxxxxxxx>
Link: https://lore.kernel.org/all/aumt-4kfGGtoXuh-@xxxxxxxxxx/
Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
MAINTAINERS | 1 +
mm/hwpoison-inject.c | 1 +
mm/internal.h | 29 -----------------------------
mm/ksm.c | 1 +
mm/memory-failure.c | 1 +
mm/memory-failure.h | 36 ++++++++++++++++++++++++++++++++++++
mm/memory_hotplug.c | 1 +
mm/page_alloc.c | 1 +
mm/page_vma_mapped.c | 1 +
mm/vmscan.c | 1 +
10 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 27d5b599558ae7..cc973903fda09d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12441,6 +12441,7 @@ F: include/linux/memory-failure.h
F: include/trace/events/memory-failure.h
F: mm/hwpoison-inject.c
F: mm/memory-failure.c
+F: mm/memory-failure.h
F: tools/testing/selftests/mm/memory-failure.c
HYCON HY46XX TOUCHSCREEN SUPPORT
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index a11222572f9789..07032ec63080e8 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -10,6 +10,7 @@
#include <linux/page-flags.h>
#include <linux/memcontrol.h>
#include "internal.h"
+#include "memory-failure.h"
static u32 hwpoison_filter_enable;
static u32 hwpoison_filter_dev_major = ~0U;
diff --git a/mm/internal.h b/mm/internal.h
index 3e15dcdd8af768..b9278329f9a239 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1196,35 +1196,6 @@ static inline bool node_reclaim_enabled(void)
return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP);
}
-/*
- * mm/memory-failure.c
- */
-#ifdef CONFIG_MEMORY_FAILURE
-int unmap_poisoned_folio(struct folio *folio, unsigned long pfn, bool must_kill);
-void shake_folio(struct folio *folio);
-typedef int hwpoison_filter_func_t(struct page *p);
-void hwpoison_filter_register(hwpoison_filter_func_t *filter);
-void hwpoison_filter_unregister(void);
-
-#define MAGIC_HWPOISON 0x48575053U /* HWPS */
-void SetPageHWPoisonTakenOff(struct page *page);
-void ClearPageHWPoisonTakenOff(struct page *page);
-bool take_page_off_buddy(struct page *page);
-bool put_page_back_buddy(struct page *page);
-struct task_struct *task_early_kill(struct task_struct *tsk, int force_early);
-void add_to_kill_ksm(struct task_struct *tsk, const struct page *p,
- struct vm_area_struct *vma, struct list_head *to_kill,
- unsigned long ksm_addr);
-unsigned long page_mapped_in_vma(const struct page *page,
- struct vm_area_struct *vma);
-
-#else
-static inline int unmap_poisoned_folio(struct folio *folio, unsigned long pfn, bool must_kill)
-{
- return -EBUSY;
-}
-#endif
-
extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long,
unsigned long, unsigned long,
unsigned long, unsigned long);
diff --git a/mm/ksm.c b/mm/ksm.c
index d24b129932bf79..623a2cdb392428 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -44,6 +44,7 @@
#include <asm/tlbflush.h>
#include "internal.h"
+#include "memory-failure.h"
#include "mm_slot.h"
#define CREATE_TRACE_POINTS
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b215312f261b83..78f0a13349cb3e 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -68,6 +68,7 @@
#include "swap.h"
#include "page_alloc.h"
#include "internal.h"
+#include "memory-failure.h"
static int sysctl_memory_failure_early_kill __read_mostly;
diff --git a/mm/memory-failure.h b/mm/memory-failure.h
new file mode 100644
index 00000000000000..153aea6c610c03
--- /dev/null
+++ b/mm/memory-failure.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * mm/ internal memory failure declarations
+ */
+#ifndef __MM_MEMORY_FAILURE_H
+#define __MM_MEMORY_FAILURE_H
+
+#include <linux/mm.h>
+
+#ifdef CONFIG_MEMORY_FAILURE
+int unmap_poisoned_folio(struct folio *folio, unsigned long pfn, bool must_kill);
+void shake_folio(struct folio *folio);
+typedef int hwpoison_filter_func_t(struct page *p);
+void hwpoison_filter_register(hwpoison_filter_func_t *filter);
+void hwpoison_filter_unregister(void);
+
+#define MAGIC_HWPOISON 0x48575053U /* HWPS */
+void SetPageHWPoisonTakenOff(struct page *page);
+void ClearPageHWPoisonTakenOff(struct page *page);
+bool take_page_off_buddy(struct page *page);
+bool put_page_back_buddy(struct page *page);
+struct task_struct *task_early_kill(struct task_struct *tsk, int force_early);
+void add_to_kill_ksm(struct task_struct *tsk, const struct page *p,
+ struct vm_area_struct *vma, struct list_head *to_kill,
+ unsigned long ksm_addr);
+unsigned long page_mapped_in_vma(const struct page *page,
+ struct vm_area_struct *vma);
+
+#else
+static inline int unmap_poisoned_folio(struct folio *folio, unsigned long pfn, bool must_kill)
+{
+ return -EBUSY;
+}
+#endif
+
+#endif /* __MM_MEMORY_FAILURE_H */
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 41fcdc04e54042..b0971404f0ac0a 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -40,6 +40,7 @@
#include <asm/tlbflush.h>
#include "internal.h"
+#include "memory-failure.h"
#include "mm_init.h"
#include "page_alloc.h"
#include "shuffle.h"
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index abebfb1f202e9b..b6d9f2c9cdef53 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -57,6 +57,7 @@
#include <linux/pgalloc_tag.h>
#include <asm/div64.h>
#include "internal.h"
+#include "memory-failure.h"
#include "mm_init.h"
#include "page_alloc.h"
#include "shuffle.h"
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index e6b6170c2f4f72..d45d52436f99a0 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -6,6 +6,7 @@
#include <linux/leafops.h>
#include "internal.h"
+#include "memory-failure.h"
static inline bool not_found(struct page_vma_mapped_walk *pvmw)
{
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 50c352e9ffefc4..3db2db65319c00 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -67,6 +67,7 @@
#include <linux/sched/sysctl.h>
#include "internal.h"
+#include "memory-failure.h"
#include "page_alloc.h"
#include "swap.h"
---
base-commit: 8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261104-memory-failure-split-4c7abedbe0dc
Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>