hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8Q58S CVE: NA
------------------------------------
Provide a way to query whether a page is hwpoioned and isolated. The driver can use this function to query if a page has beed isolated.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- include/linux/mm.h | 1 + mm/memory-failure.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h index 4e482ff01d38..7381d6b604e4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3866,6 +3866,7 @@ enum mf_flags { int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, unsigned long count, int mf_flags); extern int memory_failure(unsigned long pfn, int flags); +extern bool pfn_hwpoison_isolated(unsigned long pfn); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); extern void shake_page(struct page *p); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 228700bb5cb4..3010a20fb930 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2375,6 +2375,33 @@ int memory_failure(unsigned long pfn, int flags) } EXPORT_SYMBOL_GPL(memory_failure);
+#ifdef CONFIG_ASCEND_RAS_FEATURES +bool pfn_hwpoison_isolated(unsigned long pfn) +{ + struct page *p; + struct page *head; + + p = pfn_to_online_page(pfn); + if (!p) + return false; + + head = compound_head(p); + + if (PageHuge(p)) { + if (PageHWPoison(head) && (page_count(head) == 0 + || page_count(head) == 1)) + return true; + } else { + if (PageHWPoison(p) && (page_count(head) == 0 + || page_count(head) == 1)) + return true; + } + + return false; +} +EXPORT_SYMBOL_GPL(pfn_hwpoison_isolated); +#endif + #define MEMORY_FAILURE_FIFO_ORDER 4 #define MEMORY_FAILURE_FIFO_SIZE (1 << MEMORY_FAILURE_FIFO_ORDER)