Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp652735ybt; Wed, 24 Jun 2020 08:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjCdgkSRV6vjR7b5Pts1E5okZvdXkFohKVPy9n89bGHZv/Rw6OkzWCc3e2WHfnBGy4lflG X-Received: by 2002:aa7:d04a:: with SMTP id n10mr762972edo.132.1593011031360; Wed, 24 Jun 2020 08:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593011031; cv=none; d=google.com; s=arc-20160816; b=k7CHoi2WZE9GKiylFCmrqRau+ooyHrnh9QzAnF33gOUgqOHICZG0dSxQMkw2VutZzs TEyGoQS+FfWhy6PnygznCVTqlpdXrbtOZ8+K7PQRqVMcn/Kq1aFHtkPKMLD7MpOoUnnB i+eqoMhBhUMzgemMdCzEKJ+mQnnOBrWs7xEVQUS8zWCV2f5AhmkO+xaBcpq/D+qWrqRe FCFCqkRPtg9llsk5JJQpyUaR0IhMHOKXaviMeEeQFL5m5I5mLqIk2GBP8dgAiPsLyd2S Bp/dR+rlmheQtdcZ5ERaBOiAAeh1TzsAsTlIGNjpTDMfZyAMxpH3ESV7v8WpDLmZZhN4 nLYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=J0Xeovjt/xfdRY3CY7rSgO7sQOzE+w1RTWn+OXKgogk=; b=pMDQUm/e3IlPIRHsCSZGftVgxcEx8TdOs9VpmtyKW3Ky/sb0SB+gz8uEIuNXUR7Dq1 yT6qtmJ+Uk15QyFKDE1hNRf2Kxt3acHWsum8r3gUSPjOhbfWwnNHFICav7P968LZhFGH SXgOwmTjpn0hapBVEh3kx+gaOd2weLQ6og+OAwa1Dxq49phiD957+LmMwc4zOcwi9inz vhgaiuhGOkTsylgV4QhkRBppnOsz0zTp6p39ulx8hxf7NXqiXuU2sLKBfgZk7HvkiZnX GBLRQByAufrokXvMC3EP8xFvOPmQXUYbBzi2YBQjkO+CxiDWuk0ilv1jQbZ8MITx9xUO spLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mPAONOoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si13154074ejb.343.2020.06.24.08.03.28; Wed, 24 Jun 2020 08:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mPAONOoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404274AbgFXPCg (ORCPT + 99 others); Wed, 24 Jun 2020 11:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404249AbgFXPC0 (ORCPT ); Wed, 24 Jun 2020 11:02:26 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1346AC061573 for ; Wed, 24 Jun 2020 08:02:26 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id jz3so1280171pjb.0 for ; Wed, 24 Jun 2020 08:02:26 -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=f+/Hxni5UC826jt/WwT1s4tV9k+gq6E5/05OV0rcqRznxDoi7TjLbJPLr9yIRQ9Vol gOMte74wSNFSFLnILH/UeAdTqIbgLSWCSDqMszoflQsQPmumtO3ImoEkSzJPL5JfPYcc nubrzdjwFUbPAAWmjMo/d1ImWhaC8TD4x+PtkUHpm/CbNVwgbnFtgibShjYN0/R+EH5d AmwHJr1KABT3jIKyoT1tQLketbOHw7S+uDFGo/Z1NHu5PYel5nleLX7/FMMCN7ZUBj51 NX5WZzGJ+bXJXGJDbdormk4FQIRTPWIgJTujf4cFwZwKYqWg5OTCOLzMUi1C6UCBzqXO UNDg== X-Gm-Message-State: AOAM533IgeW+KW58pbLcwvjq64NYRGNLA1dOsqpn+9ZqNJyE1AwrVv4O bKekvHP4dMKULKPsRY9cxg== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 2.17.1