Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1624624pxa; Thu, 6 Aug 2020 11:51:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsOAo5muuqxhRK2o8oNG1sy204Jwl2Zrq8XkSvuwC2E7t8VCo/dcnPF0vJHrCKLzbQO9l1 X-Received: by 2002:a17:906:6004:: with SMTP id o4mr5908889ejj.411.1596739901365; Thu, 06 Aug 2020 11:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596739901; cv=none; d=google.com; s=arc-20160816; b=yPr0+aAwZUG9REMl9IRupHRNBzLkh2r88IXhfO5MT2i0NQ/uJBsCLSxa/JEtbF22Je +n/JSX7Q4kqm3s+bPMi5mZKuyOCwApoLB/sExw4fnH/rapolsXNowi26ZV8Zr/RHmoHK MgppOMdhHxVzpjrxaSUPi+YV4sJPD3tzeaeLqkqrmzfWbw/6ofe5S6pyHYdSRAanTpqL MLtrWQFC+cl0syWVFLXLNlfhh09WM9a34go2+jjT3cYG2YCkkAVCLlXWvwRlJNy3l7OM hu++38YekapqOCFYVyDIHeI2HZkUnuENPgQtwT6VJsF24E0zkDMU9aG2ZmQjtvokAsv0 zQiQ== 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=v5yJHduIFPrJj0jzu2BdJTc4v9IJtvWAc6ztTF7IVcQ=; b=DULmklJyOiShmMgIjzuC8oape9aqQA7/5UmcY2eeh+OPaTyeQC+kWUut0Lyia0UlFQ 7O6f/d8HtEKM3b5v4hlinAwpN2m0bDF6TQJWbXqBwhfHzpy3FfiPw6MGXaobcwCkvp3h b7Xr9thF+ZoQLrwg9W+dpD93UG2m0yf3awfOAqiR8AajELk1yQHEhNEdc44UjhqKkgoq qfNYywuon/yICqT2Dsva1YjEosKQ4l5Aplx1PxQ8o6Pn9dPBJUJSFl8oEUmtnbgHLygD FZj+MzVkkpFHVWESlR8WKqbEYqP077tZua3YMlK7Lx0CrNAhvV9ecc1J6r7gr9oL+/KB Mwuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W1Ns8dk2; 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 r25si3659916ejx.486.2020.08.06.11.51.19; Thu, 06 Aug 2020 11:51:41 -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=W1Ns8dk2; 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 S1729374AbgHFSuF (ORCPT + 99 others); Thu, 6 Aug 2020 14:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729332AbgHFSuB (ORCPT ); Thu, 6 Aug 2020 14:50:01 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 293C5C061574 for ; Thu, 6 Aug 2020 11:50:01 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id g19so15672497plq.0 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=Xw9xqi5nS6dgFajPVHfGp9DeivXZyk72raKJuJQ81SnCXxUbl5KqEzzwdMJ/xWnFBm IwUy2NR5ZGNKRlGCCLPWSCa8/AF98awT3CfUNLWVgFZyKcR76bz8f+7cj3YtCr5c0OK8 qMBi80JKAjdldQW6D+BfbEbOe5OeODv6j4Pf8GmAKwZIdGa5oubxLsttOcEPzx+DOrej 5jTsjITV9XcIt13vnRfpx4BF4pjvpFoPjFACYIVUSgnzyWcrO3ZJCrTkwbNbiPIIGSdj J+HDJMBUjWuvMeh0Avbu6TKzf6oziKx/QOnE8sXLE8lthcK0gbpccaCbz8Mxxm0a+w30 3jjA== X-Gm-Message-State: AOAM531ldc6owGpSoVjzTed29VpEjD28eqO78KQMe0VKa1GtCJ4+/TlG NoRHD0ejTJOViOvgBgR4DA== 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> 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 | 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(); -- 2.17.1