From patchwork Thu Aug 4 12:28:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: luofei X-Patchwork-Id: 12936327 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 1505EC19F2A for ; Thu, 4 Aug 2022 12:28:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77FE58E0002; Thu, 4 Aug 2022 08:28:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72F5C8E0001; Thu, 4 Aug 2022 08:28:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61EC28E0002; Thu, 4 Aug 2022 08:28:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4FCC38E0001 for ; Thu, 4 Aug 2022 08:28:54 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 228B71203EC for ; Thu, 4 Aug 2022 12:28:54 +0000 (UTC) X-FDA: 79761839388.31.12BA38A Received: from spam.unicloud.com (mx.gosinoic.com [220.194.70.58]) by imf22.hostedemail.com (Postfix) with ESMTP id C042DC00F7 for ; Thu, 4 Aug 2022 12:28:52 +0000 (UTC) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 274CSUmB018499; Thu, 4 Aug 2022 20:28:30 +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 20:28:29 +0800 From: luofei To: , CC: , , , luofei Subject: [PATCH v1] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page Date: Thu, 4 Aug 2022 08:28:19 -0400 Message-ID: <20220804122819.2917249-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 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 274CSUmB018499 ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659616133; a=rsa-sha256; cv=none; b=OWXl4nTcbDJ8+GTY/QNKkdVgAj2NYSperDgtiOSYL1UM6z7lrVWzudDak02YIOGdEMpnZO YNcg/NVPqG8NNP4V6PLZYQxtsSMT0DFU2Cj5FpeZrlhY/WQcFzxrkalal5sB7kseqIzDN1 4lqxz/+pZjaspm0QENj0nKlJxHMTHcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659616133; 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=0Y2VS0V/878538p8/sjvoxrIBDE4myzEd5JgM7BB7K8=; b=mdPx9his82dHtNZpEqd1AaMHG63l4V52srSjZQ0hBLo8w1kPknsV1Cfzlq3jdHI6dlLqix QD+kUvp8pyxq6bQJtKaTEEkiMLjQjKoU99mSi+iVd22pl/DT5+sQM1iUfW9w0YGpTtmAN1 jPkjImJxCvCTfLoJrqodl0vT6cDeg7Y= X-Rspamd-Server: rspam09 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of luofei@unicloud.com designates 220.194.70.58 as permitted sender) smtp.mailfrom=luofei@unicloud.com; dmarc=none X-Stat-Signature: jhdi58anoo3jk4q8pkh7gusjiygsa48m X-Rspamd-Queue-Id: C042DC00F7 X-HE-Tag: 1659616132-589584 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..92dbeaa24afb 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;