From patchwork Fri Jul 31 12:21:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694833 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 E1C53913 for ; Fri, 31 Jul 2020 12:21:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE2BA22B49 for ; Fri, 31 Jul 2020 12:21:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mL8mwKWQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE2BA22B49 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 872CC8D002B; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 822F48D002A; Fri, 31 Jul 2020 08:21:32 -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 6C5588D002B; Fri, 31 Jul 2020 08:21:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 4FA4A8D002A for ; Fri, 31 Jul 2020 08:21:32 -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 03C81180AD802 for ; Fri, 31 Jul 2020 12:21:32 +0000 (UTC) X-FDA: 77098281624.26.rat06_381545826f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id C56791804B640 for ; Fri, 31 Jul 2020 12:21:31 +0000 (UTC) X-Spam-Summary: 1,0,0,6e799614111fea10,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:6742: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.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrfzqiq94q9g3jxzxn4dfhj3xgropo5xecqykrj5fdmpra6fusks4ft6htu65.r83pn7dgue4hbde9xfhz6trm1oabbb5gah9hqkot5tkhk4a7u4hk6yjbbddcqm7.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:24,LUA_SUMMARY:none X-HE-Tag: rat06_381545826f83 X-Filterd-Recvd-Size: 4703 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:31 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id t15so7648294pjq.5 for ; Fri, 31 Jul 2020 05:21:31 -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=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=mL8mwKWQzTvtX66d+UAyvZYdeQfelYFSjj9rVpvye6Z3Z69SI59FpRf6OxSdCEUyh0 1uV7DKEXrssFQAvdcBXZ3OPVVqRYmOyac7+wTTDLdr+Qz6hVv7vV6bwx9Cuyl0x+58ya Yog37R4NlqRmNjaj4HUv7O+CqxVQpBjIrkrNahCOWRl5Bkw+6rLYCG1SSEn4T8gmHLi2 T8tRatkzoVK9YvK4I4N2iskRZEB1mJN4IYFco0Zb6M/bc6/XrJ4TGATj2GeX2HykwvaI f1aIXZJ82amxGxC9ysOXv/8IUR4OArtjUM6WoKZayh72LgryYTd30z7JqrPLZcpm4X1J 5Fjw== 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=C20rXtIxVYuV8kAt9ziq5r9X3XGDWqg/fkrphmJjKRQ=; b=TSv8SwIqEPW1529gyilMH9d2N0ClEKl3nLsLvDnyEtWxST1ynRNaDIZyyy+K/zTVQM slYapCmYBCeKGym3sN36Cp5y5O6XlOrln8Uf3NEmQm10Zhs6lverF6PNgyMl5v10RzcX FdljLRCUy2d4z2zP2pUET2WBpr873FDaNUPQSlbzB7u1HwzSE2CU31zwk9nylo+b73Dw jybmi+t1NRKtdPhPXUxN4IPOR5ms6pzspM7D+hYVXX4XQciVA+9Hz3BACWLJtmrSNwJP WDjOb+8MPHX6OJTD+8ACYSIzw8ZfH4RDyAqMVyKaoquAOTfv8CRGciVk5DIDmTEIZNFJ ZyVw== X-Gm-Message-State: AOAM533SPksyWBeAxISyhIcqm9ZC687TPEgjh3A1h+p6ciqHzOi1APi8 uq4lVUAGsh9fFXEqNk13SyA5mGG/Ew== X-Google-Smtp-Source: ABdhPJxBtp9vGmxG4kThIlaUgtwdMwKwb0g68uZr44relMDFK6s7Qp5rP4w+/RX5BF4lCvffoiwKlA== X-Received: by 2002:a63:3d06:: with SMTP id k6mr3577330pga.316.1596198090375; Fri, 31 Jul 2020 05:21:30 -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 m19sm3675692pjv.34.2020.07.31.05.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:29 -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, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/16] mm,madvise: Refactor madvise_inject_error Date: Fri, 31 Jul 2020 12:21:00 +0000 Message-Id: <20200731122112.11263-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: C56791804B640 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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-rc7-mmotm-2020-07-27-18-18/mm/madvise.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c index 1fe89a5b8d33..2c50c2c5673b 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/madvise.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/madvise.c @@ -886,16 +886,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); @@ -925,17 +924,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; }