From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0306C19F2D for ; Thu, 4 Aug 2022 11:50:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 379D38E0002; Thu, 4 Aug 2022 07:50:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 329768E0001; Thu, 4 Aug 2022 07:50:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 217B48E0002; Thu, 4 Aug 2022 07:50:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1676E8E0001 for ; Thu, 4 Aug 2022 07:50:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CC003C0CCC for ; Thu, 4 Aug 2022 11:50:34 +0000 (UTC) X-FDA: 79761742788.19.5B9DFF3 Received: from spam.unicloud.com (eage.unicloud.com [220.194.70.58]) by imf21.hostedemail.com (Postfix) with ESMTP id BC22B1C0139 for ; Thu, 4 Aug 2022 11:50:29 +0000 (UTC) Received: from spam.unicloud.com (localhost [127.0.0.2] (may be forged)) by spam.unicloud.com with ESMTP id 274BXrt8005800 for ; Thu, 4 Aug 2022 19:33:53 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 274BXL8d005672; Thu, 4 Aug 2022 19:33:21 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from localhost.localdomain (10.10.1.7) by zgys-ex-mb09.Unicloud.com (10.10.0.24) 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 19:33:20 +0800 From: luofei To: , CC: , , , luofei Subject: [PATCH] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page Date: Thu, 4 Aug 2022 07:33:08 -0400 Message-ID: <20220804113308.2901178-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb08.Unicloud.com (10.10.0.14) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL:spam.unicloud.com 274BXrt8005800 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659613834; a=rsa-sha256; cv=none; b=VLBVeWE3kz7wXdzSnGGV80S8M+NzzwBQyoRiqOUwHuxXLtzEaHQwrgF42IpgsODq46DVHC qhskkfiiDyzmNTVOQuxUkmLRWKB/ReY1yc1cQXUW4CBKtErmLezMEi3G6nFM1qRxH8KuMK gLkfMb5FoWbzxJJhlQVVqBs6Zmr60eY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659613834; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=VwRkSvfiwzxH1dizevOOSjmXisB3HKSXaWRYUDsRS5Y=; b=3yGKPNPYK2QB5d/osCLWDt+1hCeRLH4jxloAch1wcaYnT3e4lf82FgD8sHnvw77jg9gPU3 AYu0AJYV8eDSsdlAh7XmkgCGE+aq7nBg13T3l1VNkfuQUGnD94T6U3O/VMhi4JnZ1ytNsf 8RBCv/haSeKIXCQmb4VypNHmECreqvA= X-Rspam-User: X-Stat-Signature: xyefifsinzrbinitcknx5mzz1ftmp9qi X-Rspamd-Queue-Id: BC22B1C0139 Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com X-Rspamd-Server: rspam02 X-HE-Tag: 1659613829-21441 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 = raw_hwp_list_head(hpage); + llist_for_each_safe(tnode, t, head->first) { + p = container_of(tnode, struct raw_hwp_page, node); + if (p->page == 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 %#lx\n", pfn, &unpoison_rs); goto unlock_mutex; -- 2.27.0