Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp934845ybg; Fri, 18 Oct 2019 09:29:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzunwmUb342hZTtA9MDjzvKkC3uCxbVXAPLeQXY8c+pRGIX1DrPX3FI0GesSBBQwKXKRd4l X-Received: by 2002:a50:c90d:: with SMTP id o13mr10476750edh.85.1571416145776; Fri, 18 Oct 2019 09:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571416145; cv=none; d=google.com; s=arc-20160816; b=Ekoamlx2XFwlpqDune79IwCHVuk8S1nuQbVNP3JCEfnaKvGjdVN75NGgXJTsqlJl3J 7kpQplw9rCaIU8V+/dB1M3Pvd4+z9dWHZK7UZomSiV+XOM5gVvo6g3g6aUsexfhOJzIy tZv55vvVoRflBBQTHMu60cKt5ucKPK0/xjPjUNIEoTyBz0IPmWrlb3UBLQcv0+3DeHjg aHJ/ugCO/Vo/WbPoPeCTcnIw2W7VS0vNI3byqqY0Rh8BjpJisL8AW9qlYrSFFOpmD9LO d2EfpAgye9frXUHlEk2rUa9WTDV3fHhmqPFnToSMBwLhmxyeqdKb0fGaHKWwxoUkElvw D8Kw== 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=ShQnj1GctwKUmSzNYw/g4BzBC0Q9b3DXyMitLAptkbc=; b=dv1v8tku0GgLeAL90K4scJgvX4Ve+4foK/82IvF/J+j/mtwXWRv7z+Ei8oOkYpjoP5 LVDwGyKW+kzggVLNv+sn6dZUvA7WHH1JQByxN9O7ciIXWwP0Ahx957Q92Nu1ZRwNmtsN rDXIRcFg6WUpf1UuDHYeb3dsfOc7tlpbs+3ce8dR99c/ID5BI5azFwgG+pFuSyrDuj/v M+tSG7OD66JPFtI45gGo2O3tDWhQKfZHwMUZlrviYfVa6NS2G4NY4JMdutVGVFrHBsC/ 86kFqJi7vm+JsQ1DoXEzG9OjnJC3MHDMhTFz5XUuVsv31RPLjsYHvjelpY85wiPbr43R k2/Q== 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 q15si3699902ejj.183.2019.10.18.09.28.42; Fri, 18 Oct 2019 09:29:05 -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 S2440188AbfJQOVp (ORCPT + 99 others); Thu, 17 Oct 2019 10:21:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:40578 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440145AbfJQOVj (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 4F446B48D; 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 13/16] mm,hwpoison: Take pages off the buddy when hard-offlining Date: Thu, 17 Oct 2019 16:21:20 +0200 Message-Id: <20191017142123.24245-14-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 We need to do as we do now for soft-offline, and take poisoned pages off the buddy allocator. Otherwise we could face [1] as well. [1] https://lore.kernel.org/linux-mm/20190826104144.GA7849@linux/T/#u Signed-off-by: Oscar Salvador --- mm/memory-failure.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 48eb314598e0..3d491c0d3f91 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -791,6 +791,14 @@ static int me_swapcache_clean(struct page *p, unsigned long pfn) return MF_FAILED; } +static int me_huge_free_page(struct page *p) +{ + if (page_handle_poison(p, true, false)) + return MF_RECOVERED; + else + return MF_FAILED; +} + /* * Huge pages. Needs work. * Issues: @@ -818,8 +826,7 @@ static int me_huge_page(struct page *p, unsigned long pfn) */ if (PageAnon(hpage)) put_page(hpage); - dissolve_free_huge_page(p); - res = MF_RECOVERED; + res = me_huge_free_page(p); lock_page(hpage); } @@ -1145,8 +1152,10 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) } } unlock_page(head); - dissolve_free_huge_page(p); - action_result(pfn, MF_MSG_FREE_HUGE, MF_DELAYED); + res = me_huge_free_page(p); + if (res == MF_FAILED) + num_poisoned_pages_dec(); + action_result(pfn, MF_MSG_FREE_HUGE, res); return 0; } @@ -1307,6 +1316,12 @@ int memory_failure(unsigned long pfn, int flags) if (PageHuge(p)) return memory_failure_hugetlb(pfn, flags); + + if (is_free_buddy_page(p) && page_handle_poison(p, true, false)) { + action_result(pfn, MF_MSG_BUDDY, MF_RECOVERED); + return 0; + } + if (TestSetPageHWPoison(p)) { pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn); @@ -1328,10 +1343,10 @@ int memory_failure(unsigned long pfn, int flags) * that may make page_ref_freeze()/page_ref_unfreeze() mismatch. */ if (!get_hwpoison_page(p)) { - if (is_free_buddy_page(p)) { - action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); + if (is_free_buddy_page(p) && page_handle_poison(p, true, false)) { + action_result(pfn, MF_MSG_BUDDY, MF_RECOVERED); return 0; - } else { + } else if(!is_free_buddy_page(p)) { action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); return -EBUSY; } @@ -1354,8 +1369,8 @@ int memory_failure(unsigned long pfn, int flags) */ shake_page(p, 0); /* shake_page could have turned it free. */ - if (!PageLRU(p) && is_free_buddy_page(p)) { - action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); + if (!PageLRU(p) && is_free_buddy_page(p) && page_handle_poison(p, true, false)) { + action_result(pfn, MF_MSG_BUDDY_2ND, MF_RECOVERED); return 0; } -- 2.12.3