提交 3cdaf5f9 编写于 作者: O Oscar Salvador 提交者: Yang Yingliang

mm,hwpoison: refactor madvise_inject_error

mainline inclusion
from linux-v5.10-rc1
commit dc7560b4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4LE22
CVE: NA

--------------------------------

Make a proper if-else condition for {hard,soft}-offline.

[akpm: refactor comment]
Signed-off-by: NOscar Salvador <osalvador@suse.de>
Acked-by: NNaoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b87faca9
...@@ -638,7 +638,6 @@ static long madvise_remove(struct vm_area_struct *vma, ...@@ -638,7 +638,6 @@ static long madvise_remove(struct vm_area_struct *vma,
static int madvise_inject_error(int behavior, static int madvise_inject_error(int behavior,
unsigned long start, unsigned long end) unsigned long start, unsigned long end)
{ {
struct page *page;
struct zone *zone; struct zone *zone;
unsigned int order; unsigned int order;
...@@ -647,6 +646,7 @@ static int madvise_inject_error(int behavior, ...@@ -647,6 +646,7 @@ static int madvise_inject_error(int behavior,
for (; start < end; start += PAGE_SIZE << order) { for (; start < end; start += PAGE_SIZE << order) {
struct page *page;
unsigned long pfn; unsigned long pfn;
int ret; int ret;
...@@ -669,25 +669,23 @@ static int madvise_inject_error(int behavior, ...@@ -669,25 +669,23 @@ static int madvise_inject_error(int behavior,
if (behavior == MADV_SOFT_OFFLINE) { if (behavior == MADV_SOFT_OFFLINE) {
pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
pfn, start); pfn, start);
ret = soft_offline_page(page, MF_COUNT_INCREASED); ret = soft_offline_page(page, MF_COUNT_INCREASED);
if (ret) } else {
return ret; pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
continue; pfn, start);
/*
* Drop the page reference taken by
* get_user_pages_fast(). In the absence of
* MF_COUNT_INCREASED the memory_failure() routine is
* responsible for pinning the page to prevent it
* from being released back to the page allocator.
*/
put_page(page);
ret = memory_failure(pfn, 0);
} }
pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
pfn, start);
/*
* Drop the page reference taken by get_user_pages_fast(). In
* the absence of MF_COUNT_INCREASED the memory_failure()
* routine is responsible for pinning the page to prevent it
* from being released back to the page allocator.
*/
put_page(page);
ret = memory_failure(pfn, 0);
if (ret) if (ret)
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册