From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Xu Xin <xu.xin@linux.dev>,
Chengming Zhou <chengming.zhou@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
Johannes Weiner <hannes@cmpxchg.org>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>, Rik van Riel <riel@surriel.com>,
Harry Yoo <harry@kernel.org>, Jann Horn <jannh@google.com>,
Lance Yang <lance.yang@linux.dev>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baoquan He <baoquan.he@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-cxl@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH] mm: split out memory-failure declarations from internal.h
Date: Wed, 4 Nov 2026 17:23:24 +0000 [thread overview]
Message-ID: <autp6fWoGnnsPkbL@gremlin> (raw)
In-Reply-To: <20261104-memory-failure-split-v1-1-3b0a85f0b7e7@debian.org>
On Wed, Nov 04, 2026 at 08:45:34AM -0800, Breno Leitao wrote:
> 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@kernel.org>
> Link: https://lore.kernel.org/all/aumt-4kfGGtoXuh-@kernel.org/
> Signed-off-by: Breno Leitao <leitao@debian.org>
Thanks, nice to break this up a bit!
LGTM so:
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> 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@debian.org>
>
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-11-04 17:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:45 Breno Leitao
2026-11-04 17:23 ` Lorenzo Stoakes (ARM) [this message]
2026-11-04 20:39 ` Zi Yan
2026-11-04 22:41 ` Jose A. Perez de Azpillaga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=autp6fWoGnnsPkbL@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=brendan.jackman@linux.dev \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=jannh@google.com \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=leitao@debian.org \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=riel@surriel.com \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=xu.xin@linux.dev \
--cc=yuanchu@google.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®