From patchwork Sat Jul 8 08:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305634 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 11F8FEB64DA for ; Sat, 8 Jul 2023 08:57:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E92258D0002; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF2CC8D0007; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA6B88D0002; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7EE958D0002 for ; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3F950140157 for ; Sat, 8 Jul 2023 08:57:38 +0000 (UTC) X-FDA: 80987841396.30.8C05DC3 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 1343F4001A for ; Sat, 8 Jul 2023 08:57:34 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688806655; 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:in-reply-to:references:references; bh=t3jGnFlBe2e1gDFOxNrK0L2EElNUaiKTTYXS7V29tIw=; b=5rdJey/6yOdHcHRt8z95oIzil1iJcVM3LsB9HCg1xMEA2d6VV0/UM9QdMrp7iBGbKzjSYc xz6lJpwrm2NZFfQKsOKOvf71zAkp7z2eJcrm/F3blI78e3HXxX4RaT6rf+fci+pmXpBeTa cSTK4um2tz57PTVCpV5aJW8cW2ZmbBI= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806655; a=rsa-sha256; cv=none; b=EfVuXgg4UW7MVF7r4WbD0zrpKoTo9ilbzGjVDjX5Viahwp92uBugZqrq/6m5DkgWsEecwV /GYGsTCf9yHKUziYrATIZJVEkUOIhifln3UKNSj8WP2bHizsPZ/ZKrTYu/+kpRAPAPZniu aYqfYNCqrHYFPIX6p981B4Ayf20qa1s= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qykdf41dVzTkgk; Sat, 8 Jul 2023 16:56:22 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 8 Jul 2023 16:57:29 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 2/8] mm: memory-failure: ensure moving HWPoison flag to the raw error pages Date: Sat, 8 Jul 2023 16:57:38 +0800 Message-ID: <20230708085744.3599311-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230708085744.3599311-1-linmiaohe@huawei.com> References: <20230708085744.3599311-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: fd1gxnwo6fbt7ex6g1mj1hmwq4dahcqk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1343F4001A X-HE-Tag: 1688806654-736064 X-HE-Meta: U2FsdGVkX1+IodmaJNUFeb65ptGolSOL+WzmWioMida0foFINZkEquoXr4LusEdKUi977dqSxIZRUkbgCK5IA4myrM+aeBV1RcSFS86mDMC0rIAXVskWAExu2v1K19ENKiO4QgFX4oVGH9VUuhM+rIZU4qI0qAhHE8dNvLFYnU+In1qP6e/m9XFJb805n8zUhmSnLyEk2WCgV6deb1KULCRn88BpeYimoy5PcIxZ8/tzeCOvReWH+xTymAn0/OrT9K9fnAGDpS335J+IT2UpfC9MczlNavC7S+9GkayE+coROi3WgA3kWFFu7sunLjbn3/wnE0gC8NjWWwBb+jXD/8Rd8+nH7H84lbVAUNlo/7mi/Ry+FwSCMlOQUA0sefA9JYKzue4Sk3cPtVyD0c7+IGytwtXgw/TVR452F+ouaMFlLXXU/xLpPAR+nrCk3rIQvkRNgiPezEOJdbc48AEeaeHPcx7bRIigjl2BC46bvRZC/YOyUvLNTu0LrmpUZuBAZFpW/FhzdvmyuQtPYfjQGugKxgB61MSz1kQ5I6YK/80Yvp0VDK+sRhssQgO10hnxBvSwYC81dJvc0nT+oqkJ5TWYrSEzo8o6UXq1gmR2ca/zql2gwn1R5nZcMKh6KLzOYUpHCoJVg4cHclLtPv4hms1hNz/+i2dC7Xqcpp++GTMYc8wZAfkseNkWJvZSV5mOXqP+DVA6MHelOW+/XP0mjnHrxjz7nrmMHs/HuRKMKFErcnoSSYPvY4dcql+IWiXGu7/QmLIg4NCBTp/NIKOZqwX3cZQl/2OMzcWkddGNwIj0QFdy3aYYQmT4ox+aXuUAqPuu7TuNudSyE0iHPkJS3/AJI/4GeX3ghjCr5G3SP+f4x4Bgx/Lz6lN2x1MwCbo3j7XZxWOUlpCj1+pgvlt/Xm3+otbF19UUrExEv894RWHHaD+kKlwrOy+xgjh/SUdobzAmkVE1EnO9iqo9QkH +tYCppDQ tERUu8b4x0F4M0QSt50J9XrtVRzQ2Kx/ufSWZXmOeoJ5nhubG6FcV8NxnwKrLoEf7b2oQWPNzSB8SEH5pYvv1TwH4gBXgJTZ/PNxka+YDAxfwsqQgtrzb8JEstzNIlaxydYrwkSyLtAqh79k= 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: If hugetlb_vmemmap_optimized is enabled, folio_clear_hugetlb_hwpoison() called from try_memory_failure_hugetlb() won't transfer HWPoison flag to subpages while folio's HWPoison flag is cleared. So when trying to free this hugetlb page into buddy, folio_clear_hugetlb_hwpoison() is not called to move HWPoison flag from head page to the raw error pages even if now hugetlb_vmemmap_optimized is cleared. This will results in HWPoisoned page being used again and raw_hwp_page leak. Fixes: ac5fcde0a96a ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d21ee27ad412..c155122e3c66 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1913,6 +1913,8 @@ void folio_clear_hugetlb_hwpoison(struct folio *folio) { if (folio_test_hugetlb_raw_hwp_unreliable(folio)) return; + if (folio_test_hugetlb_vmemmap_optimized(folio)) + return; folio_clear_hwpoison(folio); folio_free_raw_hwp(folio, true); }