Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp930152ybg; Fri, 18 Oct 2019 09:25:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfOMmIj5h0aWminFn6bqeYoa9Sk3fwdgoei5zp56y1GvRiGtHG/u+F+/9IDFw+9r2x3Zp4 X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr473874ejb.96.1571415902938; Fri, 18 Oct 2019 09:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571415902; cv=none; d=google.com; s=arc-20160816; b=pUVmx/jfsFSvIAiGEO1GrJj5qImIMht2vJHK6aZN9MrGHSFBpw78Fq1kWmAzzrcdPS LuK1y6XCXCjsIuAouH6Td+xKsvTeLSeRq8v1P0nBQnEgCSeVT5Ob16/q7ZH8SIF4/1J8 dHg+p1V/jEu0I7GyueSZtiPRAdZWFaAlD1YpCfQ3dag+l1WH2mLStKjZjoYS9UvqVve2 ia8dpSCLDKg63iO0Wj5wKA9rALfF0RAzIdC/e944wxhI1g1wbo5sJds9CZEtNraYSv4x dbFyJuvLcTsWeLEaPhkkET/WDR6zh8veWtANlSa2iVmC3g+fklPGJYdB4Xjg2SKf2+Ed zGSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=XMFkhA3W5izUDG/asg04BRDdf9OzWRZ3B5tRog++ZV0=; b=Dup/Jc/mmBkGLbGV7QEFZ3AmcZSDdE4l0DxAMdcj7a/h2s2j5zZiEvZ6BBpVkAK5R2 2CsYOp+6ECDiHSX7XcQTmyBAn+9vDVlJBIcHRajF/rZHZx4xJWpVZIdi/SZbd5WN8Jwm 5wIWUR9RJ2rG5KKyWsqJCi3aSwk4yqQGxK/d8PCw2drAP5kS7tmk3BcHeHY7fI3a0hMG i+eOo3wDDIifkVyMLeXmpSc5OTi3cudU6uKaMp7W4E0XRlPWk6PQa2RfdkyOlBvAhi8h LKB1b8Epdm564vUhqdgs69Gf0xMUySBbnG61XP18KRdn0hkNXzGyifEl6becu1mYgNHr Sd8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hk1si3798139ejb.408.2019.10.18.09.24.39; Fri, 18 Oct 2019 09:25:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440146AbfJQOVh (ORCPT + 99 others); Thu, 17 Oct 2019 10:21:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:40544 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440097AbfJQOVe (ORCPT ); Thu, 17 Oct 2019 10:21:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 16343B489; Thu, 17 Oct 2019 14:21:33 +0000 (UTC) From: Oscar Salvador To: n-horiguchi@ah.jp.nec.com Cc: mhocko@kernel.org, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [RFC PATCH v2 03/16] mm,madvise: Refactor madvise_inject_error Date: Thu, 17 Oct 2019 16:21:10 +0200 Message-Id: <20191017142123.24245-4-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20191017142123.24245-1-osalvador@suse.de> References: <20191017142123.24245-1-osalvador@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make a proper if-else condition for {hard,soft}-offline. Signed-off-by: Oscar Salvador --- mm/madvise.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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; } -- 2.12.3