From: Zhang Jian zhangjian210@huawei.com
ascend inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8R318 CVE: NA
-------------------------------------------------
Collect the processes who have the page mapped via collect_procs().
@page if the page is a part of the hugepages/compound-page, we must using compound_head() to find it's head page to prevent the kernel panic, and make the page be locked.
@to_kill the function will return a linked list, when we have used this list, we must kfree the list.
@force_early if we want to find all process, we must make it be true, if it's false, the function will only return the process who have PF_MCE_PROCESS or PF_MCE_EARLY mark.
limits: if force_early is true, sysctl_memory_failure_early_kill is useless. If it's false, no process have PF_MCE_PROCESS and PF_MCE_EARLY flag, and the sysctl_memory_failure_early_kill is enabled, function will return all tasks whether the task have the PF_MCE_PROCESS and PF_MCE_EARLY flag.
Signed-off-by: Zhang Jian zhangjian210@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Reviewed-by: Kefeng Wangwangkefeng.wang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Reviewed-by: Weilong Chen chenweilong@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- include/linux/mm.h | 4 ++++ mm/memory-failure.c | 8 ++++++++ 2 files changed, 12 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h index 4e482ff01d38..4246015259ff 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3882,6 +3882,10 @@ extern int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, void num_poisoned_pages_inc(unsigned long pfn); void num_poisoned_pages_sub(unsigned long pfn, long i); struct task_struct *task_early_kill(struct task_struct *tsk, int force_early); +#ifdef CONFIG_ASCEND_RAS_FEATURES +extern void collect_procs(struct page *page, struct list_head *tokill, + int force_early); +#endif #else static inline void memory_failure_queue(unsigned long pfn, int flags) { diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 228700bb5cb4..b90e7dbf7430 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -709,8 +709,13 @@ static void collect_procs_fsdax(struct page *page, /* * Collect the processes who have the corrupted page mapped to kill. */ +#ifdef CONFIG_ASCEND_RAS_FEATURES +void collect_procs(struct page *page, struct list_head *tokill, + int force_early) +#else static void collect_procs(struct page *page, struct list_head *tokill, int force_early) +#endif { if (!page->mapping) return; @@ -721,6 +726,9 @@ static void collect_procs(struct page *page, struct list_head *tokill, else collect_procs_file(page, tokill, force_early); } +#ifdef CONFIG_ASCEND_RAS_FEATURES +EXPORT_SYMBOL_GPL(collect_procs); +#endif
struct hwpoison_walk { struct to_kill tk;