Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1183895ybh; Thu, 16 Jul 2020 05:40:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxkUt4cc55hA0RpJDpTXlFd0ULYxaLpzn2BvYrUgkJ6P6h3EpNnxWklRR8bdnMeylXVzcs X-Received: by 2002:a50:8e53:: with SMTP id 19mr4398252edx.185.1594903201169; Thu, 16 Jul 2020 05:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594903201; cv=none; d=google.com; s=arc-20160816; b=sEgggI4Ku67Q9yEzSkNzc/7btviNeYh0GBTTqQTuvhY+7ZM2hG1dlAXEpKUBNc9kjK XRJiuzegF1/1FGFYTNkiy6rCfhAwY6dvA3d2a33rJuW2nhrXgFVGRJPaKyETpUQJ7kxz ZIjm+i+VM7kw4/fGRixJNrsW3ZdeipzcO/GZ+N/H1IhaCsO6/212HR/7EBFCxgmxlObz gK6RhsDpvjzwpyfu4dvBMBXjZY1N/4UXWbQXuSmJkLuaaI/Y+QVkyVfxM6YRYiFzxYM/ xrjTydSi4BF/YrFBUcNkEWUDon3214NDvgOR+nFp7CuPiKdDIaddzm0YTlkcAA27AgNI QURg== 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; bh=Sd3WqUk9bIgXFO84Uyzyzy6jCURkou0dKgb8Ji0NXhE=; b=FagYGjzljV7VyobIdDAj4xeSxb4EeC9nF4uJE/+X7WjDAKu6fyruV/Qrozwj6ySO/i eN+aJNB4nmG9XfRCODiSq5uepZmf5QoKxi/fr9xpNqRYFLud6ImSOM6aNxgdwdXZj8uP N/NyKNdKfVq3Ana2Ze5oa5efdYmS14IehLZr1RAP1QYjuqhYDtC+N8E0Jl4l8XXD1QpU iu+UGOqNbGFG6TwzLYuP9vLTPcbC19KJmtrce04uVsISnzm+/Z+0NfGjhKOzeLsVwZaU 3KqfwxShcZarUT9vUe8dfA+sxUxGay3q6JstrKl71+rgs4HeavU4rr6x2rjg3YH4f4cK G0Lw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si3060070edm.269.2020.07.16.05.39.38; Thu, 16 Jul 2020 05:40:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728484AbgGPMit (ORCPT + 99 others); Thu, 16 Jul 2020 08:38:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:36176 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728813AbgGPMii (ORCPT ); Thu, 16 Jul 2020 08:38:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 51871B945; Thu, 16 Jul 2020 12:38:40 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, linux-mm@kvack.org, mike.kravetz@oracle.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org, Oscar Salvador , Oscar Salvador Subject: [PATCH v4 14/15] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Thu, 16 Jul 2020 14:38:08 +0200 Message-Id: <20200716123810.25292-15-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200716123810.25292-1-osalvador@suse.de> References: <20200716123810.25292-1-osalvador@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Naoya Horiguchi --- mm/madvise.c | 3 --- mm/memory-failure.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 226f0fcf0828..7b5ca96108cd 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -920,9 +920,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 a/mm/memory-failure.c b/mm/memory-failure.c index c6c83337708a..2b2aa5a76b9b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1781,7 +1781,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)) @@ -1881,7 +1881,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.26.2