From patchwork Wed Jun 24 15:01:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A7BB60D for ; Wed, 24 Jun 2020 15:03:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1741C206C0 for ; Wed, 24 Jun 2020 15:03:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OlUun5E3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1741C206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF0456B0027; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC4AA6B0028; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8AD16B0029; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id B2CD76B0027 for ; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 726761802799B for ; Wed, 24 Jun 2020 15:03:26 +0000 (UTC) X-FDA: 76964424012.26.wax00_5a0cc5926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 03922180192E2 for ; Wed, 24 Jun 2020 15:02:01 +0000 (UTC) X-Spam-Summary: 1,0,0,7d082b372f68e54c,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2898:2899:3138:3139:3140:3141:3142:3352:3876:3877:4321:5007:6114:6119:6261:6642:6653:7576:7903:8603:9413:9592:10004:11026:11473:11658:11914:12043:12114:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21444:21627:21666:21990:22119:30003:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yfgsqwf8h7asosmwg5jmxkourfaoc744tr5531hkj8ceqg15igczcjz4twad1.xixms5ugue4hbde93mhj5nom7uw1m9rnmtfhqkot5tkheppgcdt9hh3bbddcqm7.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: wax00_5a0cc5926e45 X-Filterd-Recvd-Size: 4693 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:56 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id r18so1531879pgk.11 for ; Wed, 24 Jun 2020 08:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=OlUun5E3PI4k9fogy7yVJiNq+TrLqHRnF/eCqpsxsTKrWCCHAkjh99qm8Kji4aD2gz KHzGjJmD5OaGQ/wF2rZ0iHiPc4z3oOuPThTrnL54c1Pn16OfcWOlGTv6GgToadt6HEW3 IPPESdDzY/Y8HrXQ55n4wc1scWF08vao/QkxZ8cUtcJNSZ3OGyq01R2sVgtKEGeUZat3 3269OGDWCJOyXGceEmtJd/CQqeu5PhtHTmYMqoke9YDN6yAb/WTsK6KTPkqq2klAY3ci ejtgjnMSjft5/g5uE2QYiHq3Nxd/rsLxKVMBS/tsX4chYx8Ol5YEISRvXV2kKdA4bBzZ S30g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=MvmzdV6uKgKjQQlNYKcC1IqM52slync/UaPXGIU/l1Fg16J9+QwP0oEht95C+onYoZ vKQOd/8HOW5JbZN+cD655MGcE0V6q9F3tGjSTfVVmT5X96+jVzBc0/g+VjncTupYc6vP ZrAu5Y11H8FaTFFgyDMvHpuibxfPnDyjQLKYzyd8Q3W8CQD9f6gAOHb2ft//eiUl6Mm7 uh+IB/Y33vCnJ37SAWj/fvyLiQkodcFg5LTnJErYOteF9uvNm8AdCJqUuV43N6r++NZC 5imgMjVgkZF3kEKSfEplQNbCrn4Mn8hB51y78+f1ApZnB+7ZTbfFas9Q8PLsDKRcCUYn ydKw== X-Gm-Message-State: AOAM5302yfYZg4rj90f28qOr/2UcJsAn/YdVLJnUBg203OPHeP/oKDsz UUvn03Zr7rXsd7auPmiib+vEpC5wbw== X-Google-Smtp-Source: ABdhPJy3MaesTnbKm6iBd8AhiEdgYeuKwEA3AyCjJp2Ekr7kLhIMvv7gmu1/KH+Vc+k2Wa4yMwId2A== X-Received: by 2002:a65:6710:: with SMTP id u16mr16022611pgf.45.1593010914695; Wed, 24 Jun 2020 08:01:54 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:54 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/15] mm,madvise: Refactor madvise_inject_error Date: Wed, 24 Jun 2020 15:01:26 +0000 Message-Id: <20200624150137.7052-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 03922180192E2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Oscar Salvador Make a proper if-else condition for {hard,soft}-offline. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index 275b08edd428..bee1f4ac70d6 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -869,16 +869,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 long size; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - for (; start < end; start += size) { unsigned long pfn; + struct page *page; int ret; ret = get_user_pages_fast(start, 1, 0, &page); @@ -908,17 +907,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(pfn, 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; }