From patchwork Thu Aug 6 18:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11704103 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 44F98138C for ; Thu, 6 Aug 2020 18:50:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6D47B2224D for ; Thu, 6 Aug 2020 18:50:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W1Ns8dk2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D47B2224D 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 D64066B0022; Thu, 6 Aug 2020 14:50:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9B966B0023; Thu, 6 Aug 2020 14:50:02 -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 B3D6D6B0024; Thu, 6 Aug 2020 14:50:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 9E8726B0022 for ; Thu, 6 Aug 2020 14:50:02 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 62DA13623 for ; Thu, 6 Aug 2020 18:50:02 +0000 (UTC) X-FDA: 77121033444.12.bell47_5b173ec26fb9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 2CD2E1800E907 for ; Thu, 6 Aug 2020 18:50:02 +0000 (UTC) X-Spam-Summary: 1,0,0,647277d05e1bced1,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:8603: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.214.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8thwt1d67gwfbirm6enz3pzzuxopwufk344gf34umukd8ucfrc3ajgd87a3r.jnt5yzqfs54khiydnzrkzyeqr8ycru83bz3kbkfaahxkhcrd37913rzf36ugr8w.w-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:28,LUA_SUMMARY:none X-HE-Tag: bell47_5b173ec26fb9 X-Filterd-Recvd-Size: 5625 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Aug 2020 18:50:01 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id t10so22911592plz.10 for ; Thu, 06 Aug 2020 11:50:01 -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=v5yJHduIFPrJj0jzu2BdJTc4v9IJtvWAc6ztTF7IVcQ=; b=W1Ns8dk2j6ciQE7pkh/lSVYKDfh0hFrqZoP3hVtMZZTGlngp/JpLTneCwzZN54yKTI 7Q5qCFkyMFLHKhl1U/8xFf45prH3fZeQCbOkgVWiIjrMjzIt8lPsUXBLNVQOhoZy5iVp JJbwgsEy/8Zb5pBfGNMIKe4/TWGFhwYSF9iqoYu4Zafu8GRMC3rc3qhUBHFbfMN4NtKh irkvui7bOYfmuKMdhcn0ggpkX/8kGEevhPOUXtNp+cushrLJDMja6wADSXQD/+WVkOzf eG0b44GKxQBC87wLX34S8hXXb4MVKGuj0F7ZTDnZdIvU/hu299bmVGEYTtyX8VTmdBHA wH2Q== 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=v5yJHduIFPrJj0jzu2BdJTc4v9IJtvWAc6ztTF7IVcQ=; b=nM5Mtyb/BcdQ/qPVjFAiAyxAjet9EWnjEvBz2q7Pbn5ZkCXilam6eQ2QJBZQLzTVDj iZpCPXokHHtV7RvGxU4IGiliCLtS00kTyjneR54tN3dIgZXrROKdnnFdv9Qf5nHTSOjT 1AnGXFFRSDzPIyRNC/cDSVwrOZKBvBI66L+MBulWTudQ8HTKHmoSdiWjIqz7UPfPMNaf 6wUewoXcFlPg9zQwPIqBUKiRVUY2CVd5MspUYbGyC2Rr+LrFUW+LLXY4JobNnnInQDoZ aNR3gLiMyZSpXTXYLjTxRD8k5Tu1raBwSzzVZSc3R3ttGyZPUCQJPyhM9SJPYi7Zz+/a W3pg== X-Gm-Message-State: AOAM533gsM61RlIqqjSv3a3J+iDLYASCWJqni754dufkfYUSIQGGyS/y bxzI5IB8WlT2rqPaiGIHipFZWSAIrw== X-Google-Smtp-Source: ABdhPJxRi4CrPBcRqCBlogHKcSjI51QQFz3Fod7dvSfzrksrBLVYpPdPfBO9DPZZ0Jp0S+8QsOsuKg== X-Received: by 2002:a17:902:7d81:: with SMTP id a1mr1368470plm.89.1596739800728; Thu, 06 Aug 2020 11:50:00 -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 u24sm9096730pfm.20.2020.08.06.11.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 11:50: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 v6 10/12] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Thu, 6 Aug 2020 18:49:21 +0000 Message-Id: <20200806184923.7007-11-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200806184923.7007-1-nao.horiguchi@gmail.com> References: <20200806184923.7007-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 2CD2E1800E907 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 | 5 ----- mm/memory-failure.c | 4 ++-- 2 files changed, 2 insertions(+), 7 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 a16dba21cdf6..5fa5f66468b3 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 @@ -910,11 +910,6 @@ static int madvise_inject_error(int behavior, */ size = page_size(compound_head(page)); - if (PageHWPoison(page)) { - put_page(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 3a2cd094b77f..61e20b7dd81c 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 @@ -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)) @@ -1904,7 +1904,7 @@ int soft_offline_page(unsigned long pfn, int flags) pr_info("soft offline: %#lx page already poisoned\n", pfn); if (flags & MF_COUNT_INCREASED) put_page(page); - return -EBUSY; + return 0; } get_online_mems();