diff mbox series

[RFC,v2,03/16] mm,madvise: Refactor madvise_inject_error

Message ID 20191017142123.24245-4-osalvador@suse.de (mailing list archive)
State New, archived
Headers show
Series Hwpoison rework {hard,soft}-offline | expand

Commit Message

Oscar Salvador Oct. 17, 2019, 2:21 p.m. UTC
Make a proper if-else condition for {hard,soft}-offline.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 mm/madvise.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Comments

Naoya Horiguchi Oct. 21, 2019, 7:03 a.m. UTC | #1
On Thu, Oct 17, 2019 at 04:21:10PM +0200, Oscar Salvador wrote:
> Make a proper if-else condition for {hard,soft}-offline.
> 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>

Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
diff mbox series

Patch

diff --git a/mm/madvise.c b/mm/madvise.c
index 89ed9a22ff4f..b765860a5d04 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -854,16 +854,15 @@  static long madvise_remove(struct vm_area_struct *vma,
 static int madvise_inject_error(int behavior,
 		unsigned long start, unsigned long end)
 {
-	struct page *page;
 	struct zone *zone;
 	unsigned int order;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-
 	for (; start < end; start += PAGE_SIZE << order) {
 		unsigned long pfn;
+		struct page *page;
 		int ret;
 
 		ret = get_user_pages_fast(start, 1, 0, &page);
@@ -893,17 +892,14 @@  static int madvise_inject_error(int behavior,
 
 		if (behavior == MADV_SOFT_OFFLINE) {
 			pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n",
-					pfn, start);
-
+				 pfn, start);
 			ret = soft_offline_page(page, 0);
-			if (ret)
-				return ret;
-			continue;
+		} else {
+			pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
+				 pfn, start);
+			ret = memory_failure(pfn, 0);
 		}
 
-		pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
-				pfn, start);
-		ret = memory_failure(pfn, 0);
 		if (ret)
 			return ret;
 	}