mm: split out memory-failure declarations from internal.h
Subsystems (9)
PATCH 1/1 mm: split out memory-failure declarations from internal.h
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.
--- 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(-)
MAINTAINERS +1 -0
@@ -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
mm/hwpoison-inject.c +1 -0
@@ -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 ;
mm/internal.h +0 -29
@@ -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 );
mm/ksm.c +1 -0
@@ -44,6 +44,7 @@#include <asm/tlbflush.h> #include "internal.h" +#include "memory-failure.h" #include "mm_slot.h" #define CREATE_TRACE_POINTS
mm/memory-failure.c +1 -0
@@ -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 ;
mm/memory-failure.h new file +36 -0
@@ -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 */
mm/memory_hotplug.c +1 -0
@@ -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"
mm/page_alloc.c +1 -0
@@ -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"
mm/page_vma_mapped.c +1 -0
@@ -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) {
mm/vmscan.c +1 -0
@@ -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,
Signature · 1 line
Breno Leitao <[email protected]>
Quoted 11 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.
Quoted 7 lines
Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>
Thanks, nice to break this up a bit!
LGTM so:
Quoted 197 lines
--- 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(-)MAINTAINERS +1
-0@@ -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 SUPPORTmm/hwpoison-inject.c +1
-0@@ -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 ;mm/internal.h +0
-29@@ -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 );mm/ksm.c +1
-0@@ -44,6 +44,7 @@#include <asm/tlbflush.h> #include "internal.h" +#include "memory-failure.h" #include "mm_slot.h" #define CREATE_TRACE_POINTS mm/memory-failure.c +1
-0@@ -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 ;mm/memory-failure.h new file +36
-0@@ -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 */ mm/memory_hotplug.c +1
-0@@ -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" mm/page_alloc.c +1
-0@@ -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" mm/page_vma_mapped.c +1
-0@@ -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) {mm/vmscan.c +1
-1@@ -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.gitmaster
change-id: 20261104-memory-failure-split-4c7abedbe0dc
Quoted 4 lines
Best regards,
--
Breno Leitao <[email protected]>
--
Cheers, Lorenzo
Quoted 18 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>
Quoted 13 lines
--- 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(-)
Makes sense. Thanks.
Best Regards,
Yan, Zi
Quoted 11 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.
Quoted 7 lines
Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>
LGTM:
Signature · 2 lines
cheers, jose a. p-a
Quoted 11 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.
Quoted 7 lines
Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>
LGTM. Thanks for your patch.
Thanks.
.
Quoted 11 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.
Quoted 7 lines
Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>
Quoted 12 lines
--- 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(-)
Signature · 2 lines
Sincerely yours, Mike.
Quoted 11 lines · Breno Leitao
mm/internal.hcarries 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.hand include that from those seven files that need them.Move the block as is, including
take_page_off_buddy(),put_page_back_buddy()andpage_mapped_in_vma(): they live inpage_alloc.candpage_vma_mapped.c, but are built only forCONFIG_MEMORY_FAILUREand called only frommemory-failure.c.
Quoted 8 lines
Keep the declarations private to
mm/.No functional change.
Suggested-by Mike Rapoport <[email protected]>Signed-off-by Breno Leitao <[email protected]>---
This can go through Andrew's tree.
Signature · 3 lines
Cheers, David