Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp935447ybg; Fri, 18 Oct 2019 09:29:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnx0YhmcWgh4q+KxKoUrm0nE9Tgn+ZuwmR6hV9mwlN5KTVTHJ6H8d4uRL3EewMBSfMgAHn X-Received: by 2002:a05:6402:794:: with SMTP id d20mr10908127edy.240.1571416177145; Fri, 18 Oct 2019 09:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571416177; cv=none; d=google.com; s=arc-20160816; b=uNHiatzR8RuXd6ZqA7LGOGFLHxlMW0VKboiMitk67g99/Pb2h9IPU29qDUJdFi8QZg TEIrOzJMMJio0h9jy1BKrzAXE7H6UIMWDC3KVPlj6qB3aprEulZkLOQ1bqIT5Y2oO6tN Ov7kQELa+3RO4oiHlBOoSwhrGEjLbgoqogiNrDCEAhmhkNDy9hy0yA59tO78Jq8hZDt2 dfbL2OCBThTg7BvU/N9Ne5sC27xu+TM0dVDyDjSvna7Ihyike+cxxFUWHv1U8uJrwd6L wbH/+d0r9O+gEWAS7Q6Gl99du4aR0kQwigcMr13c/IN4aMdaffGcu7DmI7Y1/Y5Ui2jA oKEg== 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=j7l8kqu1XeetP72Xwi/r4/4CfFtjiUVCZFK6/d8gNG0=; b=wZo6Q9RzN5YEsFwqVzivCy2fT/AH1KSP8fvaqfGSGdbUtbZI1RKbtHmqt6NUYXjQbi XZeA6kpXDSpRYi2KzklhCmqd6bmkQJ+RK+k4X6jolq5cNb7QsAh+pFRNvqW5hUUb1pWC qaQ5feyKk+yNL7k6j6UixIVWyQb8Wq9UH0pXkXdQGELHcJeh3Za2bURKKhC0LyKxfSW4 P2FJdcxzNCkxGUT2v+bGOywT1rctcsUb3OAfE73JYcXj62RaKaxW8m7TEHw3FgqEKtK7 irS/OAYPC4pmvqMCoGu6OQqUYuYfsV0dY6KspdGYF6MTQoVxs3jNzZ0Hu8dBQU7f4aZq ncEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si3937073edt.288.2019.10.18.09.29.13; Fri, 18 Oct 2019 09:29:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440197AbfJQOVr (ORCPT + 99 others); Thu, 17 Oct 2019 10:21:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:40648 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440147AbfJQOVj (ORCPT ); Thu, 17 Oct 2019 10:21:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B799CB489; Thu, 17 Oct 2019 14:21:37 +0000 (UTC) From: Oscar Salvador To: n-horiguchi@ah.jp.nec.com Cc: mhocko@kernel.org, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [RFC PATCH v2 14/16] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Thu, 17 Oct 2019 16:21:21 +0200 Message-Id: <20191017142123.24245-15-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20191017142123.24245-1-osalvador@suse.de> References: <20191017142123.24245-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/: Whe 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 an 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 --- 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 8a0b1f901d72..9ca48345ce45 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -887,9 +887,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 3d491c0d3f91..c038896bedf0 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1767,7 +1767,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)) @@ -1866,7 +1866,7 @@ int soft_offline_page(struct page *page) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } get_online_mems(); -- 2.12.3