From patchwork Fri Jul 31 12:21:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694853 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 12CF51392 for ; Fri, 31 Jul 2020 12:22:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C919B2087C for ; Fri, 31 Jul 2020 12:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kCcvCqps" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C919B2087C 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 53E3C8D004A; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4C9A38D0049; Fri, 31 Jul 2020 08:22:03 -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 345D58D004A; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 125E08D0049 for ; Fri, 31 Jul 2020 08:22:03 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C536C181AEF10 for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) X-FDA: 77098282884.04.maid90_460316a26f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 97F79800843D for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) X-Spam-Summary: 1,0,0,4e1eac9255474711,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2693:2898:2899:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:6261:6653:6742:7576:7903:8957:9121:9413:9592:10004:11026:11233:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13166:13229:13255:14181:14394:14721:21060:21080:21324:21444:21627:21666:21795:21990:22119:30003:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y8bpsiohx5a81bzseomwtf4idyropwufk344gf34umukd8ucjubrdu3grpa3r.jnt5yzqfs54khiydrbsqgdhkb3qup5amw3dosa49rp7pycrd37913rwzio6kknu.1-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: maid90_460316a26f83 X-Filterd-Recvd-Size: 5527 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:22:02 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id t6so3814349pjr.0 for ; Fri, 31 Jul 2020 05:22:02 -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=WtOEWqIWk9JjcgYbtTh/VY54dSMQGk3haQqeS7NhWEU=; b=kCcvCqpsvoDrNqbbF1qDxUJ0N2OqrNTvt1A+Pumffkxof23yXR2h2++hDtJO8v3+MO EI6ZHkh5XbtZezFwk1btqfeBTj8LFSQo2lA/BHPGJbH1tcKIOTje9nV4zXLHOCM3sPoO WKzKq/lB3CQ4ExGLRfTQp9Xt7ARE4dZqkszoVq6WvFqeO5CldcZWfaA409/I98IaBJvI zPaGvjwR+uIW8Rge+vf8QYP6GpD7zRnLVD+AIIvGxBg0rqGC0DJ+JrR/0o3gRIqaxDsz +0c8k1q86E2N5X8jmk7kDleDuI7dmKKPjlJ7yjk+TojGEPbGT1hURQsNRgPUEANbxSZX B8JQ== 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=WtOEWqIWk9JjcgYbtTh/VY54dSMQGk3haQqeS7NhWEU=; b=Sm53yS2Pw1Up03xJ0B5BRDv/edKYlA46WV31FlyjnmXo4c+jq7iaSxQm/bg0H467JN udp5TcwX2Y0z6aRjFckItOEwP5zNEyqWd/W4vACkNMjBTS6R0j0jUXR0eV9c+cjrNMki SENHEz/T30KHdpmoZN39LxmHqkDqXzEQ2Zixj0rKmwZaJGO4ja/2WJFaZB+wue84Xm7p 0fF9rlyy9x8eewfJbNGJ3Thgo/WIgTAXbGfXyg93BidKtD2jiPxQqbqQSxDgqxeZZIYQ 8iT1YmiWfiKo9knqVhYuzYn2vYMdqLyoXRXzKn05t4wCzj5X7jfo6yZWq54EqryCFw1Q r25Q== X-Gm-Message-State: AOAM530DXZQMI7vRAxUhVmovQjewwlIS2Otf6SCXuiU940dGGjJ1B0Xf t0lPIMxodOHQRcrWwGgx+ANJK7gODQ== X-Google-Smtp-Source: ABdhPJx5uVsf47BpfzXr8xTEgB/mU5aV20nGmkRnVlJdXZhe6/OTqDHY+RruvzRyJLF6G3+IkBf3Gw== X-Received: by 2002:a65:6650:: with SMTP id z16mr3667397pgv.161.1596198121188; Fri, 31 Jul 2020 05:22:01 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:22:00 -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 14/16] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Fri, 31 Jul 2020 12:21:10 +0000 Message-Id: <20200731122112.11263-15-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: 97F79800843D 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 Currently, there is an inconsistency when calling soft-offline from different paths on a page that is already poisoned. 1) madvise: madvise_inject_error skips any poisoned page and continues the loop. If that was the only page to madvise, it returns 0. 2) /sys/devices/system/memory/: When calling soft_offline_page_store()->soft_offline_page(), we return -EBUSY in case the page is already poisoned. This is inconsistent with a) the above example and b) memory_failure, where we return 0 if the page was poisoned. Fix this by dropping the PageHWPoison() check in madvise_inject_error, and let soft_offline_page return 0 if it finds the page already poisoned. Please, note that this represents a user-api change, since now the return error when calling soft_offline_page_store()->soft_offline_page() will be different. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 3 --- mm/memory-failure.c | 4 ++-- 2 files changed, 2 insertions(+), 5 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 3eee78abdbec..843f6fad3b89 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 @@ -919,9 +919,6 @@ static int madvise_inject_error(int behavior, */ put_page(page); - if (PageHWPoison(page)) - continue; - if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); diff --git v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 904dec64da6b..bd63f1f2e44e 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c @@ -1794,7 +1794,7 @@ static int __soft_offline_page(struct page *page) unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } if (!PageHuge(page)) @@ -1895,7 +1895,7 @@ int soft_offline_page(unsigned long pfn) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } get_online_mems();