Commit dc7560b4 authored by Oscar Salvador's avatar Oscar Salvador Committed by Linus Torvalds

mm,hwpoison: refactor madvise_inject_error

Make a proper if-else condition for {hard,soft}-offline.
Signed-off-by: default avatarOscar Salvador <osalvador@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qian Cai <cai@lca.pw>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Aristeu Rozanski <aris@ruivo.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Dmitry Yakunin <zeil@yandex-team.ru>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Link: https://lkml.kernel.org/r/20200908075626.11976-3-osalvador@suse.deSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7e27f22c
...@@ -872,7 +872,6 @@ static long madvise_remove(struct vm_area_struct *vma, ...@@ -872,7 +872,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 long size; unsigned long size;
...@@ -882,6 +881,7 @@ static int madvise_inject_error(int behavior, ...@@ -882,6 +881,7 @@ static int madvise_inject_error(int behavior,
for (; start < end; start += size) { for (; start < end; start += size) {
unsigned long pfn; unsigned long pfn;
struct page *page;
int ret; int ret;
ret = get_user_pages_fast(start, 1, 0, &page); ret = get_user_pages_fast(start, 1, 0, &page);
...@@ -904,16 +904,10 @@ static int madvise_inject_error(int behavior, ...@@ -904,16 +904,10 @@ 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(pfn, MF_COUNT_INCREASED); ret = soft_offline_page(pfn, MF_COUNT_INCREASED);
if (ret) } else {
return ret;
continue;
}
pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
pfn, start); pfn, start);
/* /*
* Drop the page reference taken by get_user_pages_fast(). In * Drop the page reference taken by get_user_pages_fast(). In
* the absence of MF_COUNT_INCREASED the memory_failure() * the absence of MF_COUNT_INCREASED the memory_failure()
...@@ -922,6 +916,8 @@ static int madvise_inject_error(int behavior, ...@@ -922,6 +916,8 @@ static int madvise_inject_error(int behavior,
*/ */
put_page(page); put_page(page);
ret = memory_failure(pfn, 0); ret = memory_failure(pfn, 0);
}
if (ret) if (ret)
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment