From patchwork Wed Jun 24 15:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623405 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 93DEE912 for ; Wed, 24 Jun 2020 15:04:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5766F206C0 for ; Wed, 24 Jun 2020 15:04:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mPAONOoO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5766F206C0 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 53B956B002F; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 513946B0031; Wed, 24 Jun 2020 11:04:34 -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 3B42A6B0032; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id 214996B002F for ; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C8DD7180AC16E for ; Wed, 24 Jun 2020 15:04:33 +0000 (UTC) X-FDA: 76964426826.22.scale29_400576726e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id DA5F418039609 for ; Wed, 24 Jun 2020 15:02:29 +0000 (UTC) X-Spam-Summary: 1,0,0,180bb8ef8b1de359,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:7576:7903:8957:9121:9413:9592:10004:11026:11233:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13166:13229:13255:14181:14394:14721:21060:21080:21324:21444:21611:21627:21666:21795:21990:22119:30003:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrwfjjnwnomhetjnp6pwxf1y8r7opwufk344gf776oe8mqznwstuswce6gc5u.765gipr8cqueafjdjwytnmcd3bqup5amw3dosa49rp7pnp676f15zkwzio6kknu.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:23,LUA_SUMMARY:none X-HE-Tag: scale29_400576726e45 X-Filterd-Recvd-Size: 5515 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:27 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ne5so1267653pjb.5 for ; Wed, 24 Jun 2020 08:02:27 -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=J0Xeovjt/xfdRY3CY7rSgO7sQOzE+w1RTWn+OXKgogk=; b=mPAONOoOMCz3IzPvpOtPAvFkSpNOWWK64tYeTcGp6deJ7CGiQdTIbJCV2Oq5KqScuO ADRvQ4+VVqQBfUd0xqxLtL5HOjaJKhJGpU/WYe8APPid8XYqspwYo1OuZqTS7Nm22CiQ dmociYAaoYOUH0EqVKScWSV8fzliM2Gt2mSfUAFL8rSsvHv1vAxPpTXX6XhyMO0wgIz0 2QmyCW3M3bAByYly33meuPj7eq64fO2j+tSP7MDEmaZ76LbcUiEIDIcU4llqohRiD/QA O54Zk7e6ZJyVtnWggGSBqR1lqlmXON+xERUiXIGJU73FIak4foWAfIvj0FdlrHopRmji Z0GQ== 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=J0Xeovjt/xfdRY3CY7rSgO7sQOzE+w1RTWn+OXKgogk=; b=F1X5ley2wYzBOTsQdzQ/+8oRSWK6Bcx5uiiFb9wHHGxE2VMlO1NP5xSgh0D8z7WLqF OgfRXPlPOuVIuI8oLX9dfeGb47+W1d0qFG7UcjyqSKw9M+nywNe1sO+N1vMpUYCFRXKA 46UR4ECA7sWm8ixENO5aqcjpNv8p1/LH1X2ufaV/HD90PfMRrioVoN06oaZVnOJKkhD6 bn+2bNiqdfnJmkLZMjeegz2oGIY9ZAfzbTKSUeUD2Gi/uYXTFngnWwIKAbFoSO3gOiYy /hYKgfjq3NtikG1ApCG0qeUnOY5K5IsegON/BxqUtQgihySDOlsbVLa5AxS6Hq02SAs1 ulmQ== X-Gm-Message-State: AOAM531zdkMtRrhAq8U3Mds21viAy60+54ZUeKp5aGxUGCvPseKgWDHi jX4rgo9JDcixEcjGAZenMhB1ukDuiw== X-Google-Smtp-Source: ABdhPJw6MfmyFpw8wUaLuJ/Vb231TF9GIf25hqGNAuaS+lTOsKaFPSQMkwSVd0NnleNPPJ4y5vKcQg== X-Received: by 2002:a17:90a:e801:: with SMTP id i1mr28012066pjy.79.1593010945548; Wed, 24 Jun 2020 08:02:25 -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.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:25 -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 14/15] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Wed, 24 Jun 2020 15:01:36 +0000 Message-Id: <20200624150137.7052-15-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: DA5F418039609 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 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-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index 2b5080253406..b59bbd6c9982 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 @@ -902,9 +902,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-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 22c904f6d17a..9ad3198a3954 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1800,7 +1800,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)) @@ -1901,7 +1901,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();