From nobody Sun Apr 12 00:02:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6411AC19F2B for ; Thu, 4 Aug 2022 12:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239652AbiHDMIj (ORCPT ); Thu, 4 Aug 2022 08:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239565AbiHDMIi (ORCPT ); Thu, 4 Aug 2022 08:08:38 -0400 Received: from spam.unicloud.com (gw.haihefund.cn [220.194.70.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC0A51A0E for ; Thu, 4 Aug 2022 05:08:25 -0700 (PDT) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 274C7r4m014658; Thu, 4 Aug 2022 20:07:53 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from zgys-ex-mb09.Unicloud.com (10.10.0.24) by zgys-ex-mb10.Unicloud.com (10.10.0.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Thu, 4 Aug 2022 20:07:53 +0800 Received: from zgys-ex-mb09.Unicloud.com ([fe80::eda0:6815:ca71:5aa]) by zgys-ex-mb09.Unicloud.com ([fe80::eda0:6815:ca71:5aa%16]) with mapi id 15.01.2375.017; Thu, 4 Aug 2022 20:07:53 +0800 From: =?gb2312?B?wt63yQ==?= To: "naoya.horiguchi@nec.com" , "akpm@linux-foundation.org" CC: "linmiaohe@huawei.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: =?gb2312?B?tPC4tDogW1BBVENIXSBtbSwgaHdwb2lzb24sIGh1Z2V0bGI6IENoZWNrIGh1?= =?gb2312?B?Z2V0bGIgaGVhZCBwYWdlIGh3cG9pc29uIGZsYWcgd2hlbiB1bnBvaXNvbiBw?= =?gb2312?Q?age?= Thread-Topic: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page Thread-Index: AQHYp/YA2P+b2sgj8UGtO/UrSrrbAq2epYGn Date: Thu, 4 Aug 2022 12:07:53 +0000 Message-ID: <85ab16d0a56c4942bb8a3e67b9d55858@unicloud.com> References: <20220804113308.2901178-1-luofei@unicloud.com> In-Reply-To: <20220804113308.2901178-1-luofei@unicloud.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.1.7] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DNSRBL: X-MAIL: spam.unicloud.com 274C7r4m014658 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sorry, wrong patch, please ignore this email. ________________________________________ =E5=8F=91=E4=BB=B6=E4=BA=BA: =E7=BD=97=E9=A3=9E =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2022=E5=B9=B48=E6=9C=884=E6=97=A5 19:= 33:08 =E6=94=B6=E4=BB=B6=E4=BA=BA: naoya.horiguchi@nec.com; akpm@linux-foundation= .org =E6=8A=84=E9=80=81: linmiaohe@huawei.com; linux-mm@kvack.org; linux-kernel@= vger.kernel.org; =E7=BD=97=E9=A3=9E =E4=B8=BB=E9=A2=98: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page = hwpoison flag when unpoison page When software-poison a huge page, if dissolve_free_huge_page() failed, the huge page will be added to hugepage_freelists. In this case, the head page will hold the hwpoison flag, but the real poisoned tail page hwpoison flag is not set, this will cause unpoison_memory() fail to unpoison the previously poisoned page. So add a check on hugetlb head page, and also need to ensure the previously poisoned tail page in huge page raw_hwp_list. Signed-off-by: luofei --- mm/memory-failure.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 14439806b5ef..fc571b0ceb9d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2293,6 +2293,28 @@ core_initcall(memory_failure_init); pr_info(fmt, pfn); \ }) +static bool hugetlb_page_head_poison(struct page *hpage, struct page *page) +{ + struct llist_head *head; + struct llist_node *t, *tnode; + struct raw_hwp_page *p; + + if (PageHuge(page) && PageHWPoison(hpage) && HPageFreed(hpage)) + return false; + + if (HPageRawHwpUnreliable(hpage)) + return false; + + head =3D raw_hwp_list_head(hpage); + llist_for_each_safe(tnode, t, head->first) { + p =3D container_of(tnode, struct raw_hwp_page, node); + if (p->page =3D=3D page) + return true; + } + + return false; +} + /** * unpoison_memory - Unpoison a previously poisoned page * @pfn: Page number of the to be unpoisoned page @@ -2330,7 +2352,7 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (!PageHWPoison(p)) { + if (!PageHWPoison(p) && !hugetlb_page_head_poison(page, p)) { unpoison_pr_info("Unpoison: Page was already unpoisoned %#l= x\n", pfn, &unpoison_rs); goto unlock_mutex; -- 2.27.0