提交 d027122d 编写于 作者: N Naoya Horiguchi 提交者: Andrew Morton

mm/hwpoison: move definitions of num_poisoned_pages_* to memory-failure.c

These interfaces will be used by drivers/base/memory.c by later patch, so
as a preparatory work move them to more common header file visible to the
file.

Link: https://lkml.kernel.org/r/20221024062012.1520887-3-naoya.horiguchi@linux.devSigned-off-by: NNaoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: NMiaohe Lin <linmiaohe@huawei.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Yang Shi <shy828301@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
上级 e591ef7d
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/pgtable.h> #include <linux/pgtable.h>
#include <linux/swap.h> #include <linux/mm.h>
#include <linux/swapops.h>
#include <asm/pdc.h> #include <asm/pdc.h>
#include <asm/pdcpat.h> #include <asm/pdcpat.h>
......
...@@ -3279,12 +3279,17 @@ extern int soft_offline_page(unsigned long pfn, int flags); ...@@ -3279,12 +3279,17 @@ extern int soft_offline_page(unsigned long pfn, int flags);
#ifdef CONFIG_MEMORY_FAILURE #ifdef CONFIG_MEMORY_FAILURE
extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
bool *migratable_cleared); bool *migratable_cleared);
extern void num_poisoned_pages_inc(void);
#else #else
static inline int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, static inline int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
bool *migratable_cleared) bool *migratable_cleared)
{ {
return 0; return 0;
} }
static inline void num_poisoned_pages_inc(void)
{
}
#endif #endif
#ifndef arch_memory_failure #ifndef arch_memory_failure
......
...@@ -581,8 +581,6 @@ static inline int is_pmd_migration_entry(pmd_t pmd) ...@@ -581,8 +581,6 @@ static inline int is_pmd_migration_entry(pmd_t pmd)
#ifdef CONFIG_MEMORY_FAILURE #ifdef CONFIG_MEMORY_FAILURE
extern atomic_long_t num_poisoned_pages __read_mostly;
/* /*
* Support for hardware poisoned pages * Support for hardware poisoned pages
*/ */
...@@ -597,17 +595,7 @@ static inline int is_hwpoison_entry(swp_entry_t entry) ...@@ -597,17 +595,7 @@ static inline int is_hwpoison_entry(swp_entry_t entry)
return swp_type(entry) == SWP_HWPOISON; return swp_type(entry) == SWP_HWPOISON;
} }
static inline void num_poisoned_pages_inc(void) #else
{
atomic_long_inc(&num_poisoned_pages);
}
static inline void num_poisoned_pages_sub(long i)
{
atomic_long_sub(i, &num_poisoned_pages);
}
#else /* CONFIG_MEMORY_FAILURE */
static inline swp_entry_t make_hwpoison_entry(struct page *page) static inline swp_entry_t make_hwpoison_entry(struct page *page)
{ {
...@@ -618,15 +606,7 @@ static inline int is_hwpoison_entry(swp_entry_t swp) ...@@ -618,15 +606,7 @@ static inline int is_hwpoison_entry(swp_entry_t swp)
{ {
return 0; return 0;
} }
#endif
static inline void num_poisoned_pages_inc(void)
{
}
static inline void num_poisoned_pages_sub(long i)
{
}
#endif /* CONFIG_MEMORY_FAILURE */
static inline int non_swap_entry(swp_entry_t entry) static inline int non_swap_entry(swp_entry_t entry)
{ {
......
...@@ -74,6 +74,16 @@ atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); ...@@ -74,6 +74,16 @@ atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
static bool hw_memory_failure __read_mostly = false; static bool hw_memory_failure __read_mostly = false;
inline void num_poisoned_pages_inc(void)
{
atomic_long_inc(&num_poisoned_pages);
}
static inline void num_poisoned_pages_sub(long i)
{
atomic_long_sub(i, &num_poisoned_pages);
}
/* /*
* Return values: * Return values:
* 1: the page is dissolved (if needed) and taken off from buddy, * 1: the page is dissolved (if needed) and taken off from buddy,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册