From patchwork Sat Jul 8 08:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305629 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 7D8C6EB64DA for ; Sat, 8 Jul 2023 08:57:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DCCC8D0001; Sat, 8 Jul 2023 04:57:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5660A6B0072; Sat, 8 Jul 2023 04:57:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 406FB8D0001; Sat, 8 Jul 2023 04:57:37 -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 2C8DF6B0071 for ; Sat, 8 Jul 2023 04:57:37 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E2A7016012C for ; Sat, 8 Jul 2023 08:57:36 +0000 (UTC) X-FDA: 80987841312.04.6D505D3 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf20.hostedemail.com (Postfix) with ESMTP id 5030B1C0013 for ; Sat, 8 Jul 2023 08:57:33 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=siqyqEQqcZcu+EoB6yg/PvLeK5wfKJfieQ8mYyUCAufPwwmOPbALIsrDRSfciRXd2rKcms JBd9c1irQqaOeT6KxWeg6iWHnqy1Z5wftCpwtK4A0kAI4VNHrWqlagDEy1KnIR7Dk3+ODl t+TJLJgyG0QgftCTwIjyXN3jJnO0lyE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=nu0T+4OifjpWSZTiUfF2QlfBWJeikYeHAbyQgFEM6So=; b=mv0p25NPMsxr2dozWyuW51qpAA1Z2g+oBtpSrTn/gW+T088g09TbF2SBNFuO4JdvHstlYf WJMJ9zNXNNcxy7ayaHzE7mZGq4Bnl2zrCwh+KHkWNQXY/GwtV0n+LAb6dpM9L+pxWlChOh XDn08BOPWDChaswFh7jMcJnSDXC97pw= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QykbZ0mThztQRv; Sat, 8 Jul 2023 16:54:34 +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:28 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 1/8] mm: memory-failure: fix potential permanently locked hpage Date: Sat, 8 Jul 2023 16:57:37 +0800 Message-ID: <20230708085744.3599311-2-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5030B1C0013 X-Stat-Signature: kwqksmczhj497qmq69wsfu7i6tm4c7wk X-Rspam-User: X-HE-Tag: 1688806653-890382 X-HE-Meta: U2FsdGVkX1/YRsH8Ub1QVWKQ+aq5EuyeOIU+Hvpo/xHyFvxsq0CfjyhHbooy8wu+yWinnPwggG4eQCM5qpg49BI48jPFpdHzMbnYTrzSZSWo6BgDvXIL52onxuou1Ceel4ZkN4N5bFZaD2FW8nEPtXlX2idSMp1SLnFYRWHwlv2+sYVFB2HqO/XVy2QpVBDB0EA/wGChjgWMDPmwuf13x8xFC6NEAR6nxzs//TNpX577x13Xd/D4n4azWHbpSpb0YUNDQzidRdVTipmPicg53+qYsaSdEacSQ/6VjG/R8AOoiI8+YlaHGX/cLZZ28k1gevzEEVb1fj5UpJpVWbxI835rueZiYDYeI/S+rx7kRbnKENHmrOUNgGTkPPkEIanzoEC/fUB2UkaObfdOUz6hbDi06TjBsEkJ5k8Xvvc8j4DVIaNq2uNEjTJsNK4osoCUwu5v89C0Igs5Epwhci/QyNu1iba0M0eE31EXH0FRi1gMqiTAEWQGca/wrvB2uXhJqCmA/ZnOW2Z+/t2oUHWQIoIXB6IiOU67nNF3wsvAJN2HT5kI63vw8Hzlx8nCZEafefshGVlaZAXUPCaw+j1v3BwZRc/AqoEhF2PCv5eB6bK2d0tW0/HmsPfRuDc0lemE2PlBw5GspX9Js4Z8JVHQUFcnBwdd5yzH0Npp/FizPMWDCgzXWEEpYLeAr90E2Eg4L/mRHOGSvFaXwrth0M9RtqCmRO/YZJbol7xZFicVgTOVgawHKj7RvIMrACf8VvxO8hhSBOrilXhYa01iwsF0cn7ut8ynzMDzE1I7sNxt5pvfv2e4QtG+pP/Y3hVBkVuMJXLP6OV1BjRQMRIshKcPAOhF1Wm48PCqeAO9CHEicVu9PRGVaHYUJOVr8NFZ/bes5bA/jGjjNXrUg9J4/u5Qn1eJtXIQVEg6ybmFBM+aXKAlYI3ThSCUPFHDuo7C3NiVMzPzjVOboPnnDABdUPY PqYRy6MW B0b+P8NWSq6f5jkZmyBCW10kvoV0HafWFEZKL06lJBWkRySWRx/P+lpUg0g7q9gX0KK/Ahy/xRZxAE4wTnuH1G94mtOR/+xekG/ZJNi/L3e1m+HUpXoHKIrwlYgoclhLyfOvwzbjc34XZMtlI8E3fH9z+8UnwvFzgcPaRPUEM3tvUls8= 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 hpage isn't Hugetlb page, MF_DELAYED is returned without unlock hpage leading to hpage permanently locked. But this shouldn't trigger in the real world because this PageHuge() check is just for potential problems. Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index a6221a4bc5ea..d21ee27ad412 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1187,8 +1187,10 @@ static int me_huge_page(struct page_state *ps, struct page *p) struct address_space *mapping; bool extra_pins = false; - if (!PageHuge(hpage)) + if (!PageHuge(hpage)) { + unlock_page(hpage); return MF_DELAYED; + } mapping = page_mapping(hpage); if (mapping) { 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); } From patchwork Sat Jul 8 08:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305631 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 BB691EB64DD for ; Sat, 8 Jul 2023 08:57:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 393108D0003; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31C4C8D0002; 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 1BD9E8D0003; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F2E368D0002 for ; Sat, 8 Jul 2023 04:57:37 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BEA444014A for ; Sat, 8 Jul 2023 08:57:37 +0000 (UTC) X-FDA: 80987841354.30.98E0C17 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf15.hostedemail.com (Postfix) with ESMTP id 52B8EA000B for ; Sat, 8 Jul 2023 08:57:34 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806655; a=rsa-sha256; cv=none; b=QTBF1NdPJS+1bmOV3/xLbc4ftZczumgR5U/Qkx82X6d3OMII4wUQy/yJbNlA7dhi36S1an nYxgN/uMx1FUILGzpQ61xA5c2xmNexVucln0oaRhX+xdkADZz+aEc3UrFAGefJdefV9yM7 goajiSjZUomCxiRBnyTJrwjMfnkskcg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=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=xHd3BS8xVECX7E/sxvVqFWVpfjPb2IafD1iyx6RNnLk=; b=EnlRCPQ3AMzQTPqB3d5jzN99egg00NlcOkoBVeo1KJoQKfwM+jmjeTNk1ONX1QCMaQSdcp A3/tm7cmc8UczH1/sQmpqbOuQLuzrSeDWxzML0oExtVBZO7Rd6iIUFoW06vm3jnT1eU0wI JqXbtVNnYrL9z7vrXRr997AED5QUBDE= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QykfN4sfWz1FDfX; Sat, 8 Jul 2023 16:57:00 +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 3/8] mm: memory-failure: Don't account hwpoison_filter() filtered pages Date: Sat, 8 Jul 2023 16:57:39 +0800 Message-ID: <20230708085744.3599311-4-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 52B8EA000B X-Stat-Signature: qxcc4n7kxm3td3pg1kshdg9167o864n5 X-HE-Tag: 1688806654-922933 X-HE-Meta: U2FsdGVkX197fdbYPNMGYpk/uRRePt0CH/cHKdvxmyle6+YRf6rWx6lJz0dZS6ec8gcd6n2rRE1U6ami7JNrjZ9SeiSwwlEjiaWKR5ecAPF44AaSShYipMGYYHshMf8b24Aph4XPp9mKym7Dl8BRBDqculRegucmVk7yP+uQ+jDYgxdMVYPu3Ml+uLJR6mICJD2LmCf8iBiICwRrPXgy/y5vCp/TFoVSQ1HWFzhbaM+IfSSmquj7NsUEXrDCSD1zVpaLPSkyCma9Gc1/4EkT6qjRssQEztxd07tFhvT04vJaAMBUBAtl9WvBtZ91gz9e9NUvZWjDyGAz94KQGT/n1zwzeBO2oW8nqOjzGBKXon40XIy+uaaqj7NaEHKz6PVGrKkxx0BUpMuTcWnIEF7Ibsl7l9+F8NaAIKPXjZLxWSkhs7afTOnee1dIPD4GYX64kpqE4FqmlNSd4GEMqGrsTgbjxyrw+mBJ/5d876PjPyncsap/ydEWquoiepUonS4PFyEwBsWUFpfy47SmwbMd46XXpxHwYPIOUeO4n08qNxtCiUGUO+MocfCimK2d42jfZB7YvlcLKKoqTj8U+AyRSJ1S0QIfucM+ZqJ9kdyWjDqrL32AEl0n89j/jXyKYqTne0YCtn5zAhPYfSCaZS7V7nh/2Wtwc2KBSm5i3KEBj+oZ7Tpi+zYapafO8hWZC9xoWnpweVBpr7LdVUeETuSQIso/fg9e8K9kXZrd0A9COLbANYNrcd3AR4N8AI+p9a9BlrScGL2YvNU302xedYlskMkFgJAgSlMN3hM9eqo8b6kBPh5fJYpci6SnY6ZeXSB6cHfuATmmijiar4pMxVHz8V6vD5jPo0ancn9Tcp72Jdd6v9lUHI7SA8eVUF/sQwPherV0N8gvFSunSzbzL44CwrS8BDpwho4epGU/eWLLUS+xXstgPCa7nq6LkrGUCGQhB7uphFY4u9gN8J8Q9Mg 3qkEksAc XOzMas2UKnY2V3DDyOsMbK/JyRqAUMPGjPor61QUrzeZE875LNyoj86BjyJZDs6+dpulternqWji5hSxvP5UDqAbElBqMS8ncnhUeOPLa48xLNNbrkpN/65tXnB++HBlQE76h01hOmF/+OGprOoZ0CuJ4FssbK766CcAi21BZIvfb7vjh3P9bvXZlVJXTbIh0Fyht 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: mf_generic_kill_procs() will return -EOPNOTSUPP when hwpoison_filter() filtered dax page. In that case, action_result() isn't expected to be called to update mf_stats. This will results in inaccurate but benign memory failure handling statistics. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c155122e3c66..905758af70f3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2101,7 +2101,8 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, out: /* drop pgmap ref acquired in caller */ put_dev_pagemap(pgmap); - action_result(pfn, MF_MSG_DAX, rc ? MF_FAILED : MF_RECOVERED); + if (rc != -EOPNOTSUPP) + action_result(pfn, MF_MSG_DAX, rc ? MF_FAILED : MF_RECOVERED); return rc; } From patchwork Sat Jul 8 08:57:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305635 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 499B3EB64DC for ; Sat, 8 Jul 2023 08:57:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE3F18E0005; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C45168D0006; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FBDD8D000A; Sat, 8 Jul 2023 04:57:39 -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 7C9308D0006 for ; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 59A6DA0147 for ; Sat, 8 Jul 2023 08:57:39 +0000 (UTC) X-FDA: 80987841438.16.A1D05C6 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 1B8B940002 for ; Sat, 8 Jul 2023 08:57:36 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1688806657; 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=LCrOy4OLsHpFK0OuO84MTfILpCt87VTlpXIdT2mKjQg=; b=AdE1AgkE8l8Z7TQE6CC1Q5uk7XTcXZQTVePbEgUdDB1pUHxszwrfZryRf14jhfxKnuAV/g xHj1IcPiejK9+mImdu4xGm9BCfvpJHrI1pUrgqzf8noE9sld/b3OU/MeUzE4jS0z6OV2RC 8NvfJ4dKU49sy8bQtz2gLBSVEWwRLkE= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806657; a=rsa-sha256; cv=none; b=PN94cmyLbDxP37YxmboHtfGWKlp9ZVysW4tYPp0OFvzxVH/T8gtX9zY6ZRclpuy3QcgjVC XrGUQ10w6arZgQWGqzsJpZBeQIfYWkiRLxOt6dIcudGWBCWUqoV6gBtHRA3AjTaeBn6DDl 5xVujiypXUeucuSGbx7R4YD2Yuk8xA0= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QykcL4RbFzPk0X; Sat, 8 Jul 2023 16:55:14 +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 4/8] mm: memory-failure: use local variable huge to check hugetlb page Date: Sat, 8 Jul 2023 16:57:40 +0800 Message-ID: <20230708085744.3599311-5-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: 1jttu9ft7i53i7jqm4tuc44r7xpta8ac X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1B8B940002 X-HE-Tag: 1688806656-720207 X-HE-Meta: U2FsdGVkX1/FSFKVMtUWdYpEDf7hy9otZehY/g2p4SnsnJcj5S0aeW6VlHn/9yUsc/wlcZVHL/QMh2WHcazkU/TGK/k1dnKvXFFxIhsJKeJQx5faVNKHFeB0/fy1y5yL7r7bDquuKFCH3lFIrNAjZrANo8ZAvtNRoPMhe6W0YPJHfzHLrNrwJ7msDDT7ZVdVLWD4hqxKpYL0CSIO1iP89cflO43karP8YEqhsiEykAEtv/Y8+8HuG2fFO4E4JQDRLz2Rh/9TzpEDI/RYy2/flQrMnNQTQY0JouxK2AhlKdzjKdCr6bQbyPrnFqyMcNonBWBLlcgkHI1EY3CtsQa6lo69CZO9l5rd3kihtX+KOAR8PLeI2ud9Wxgxzaij2jphKgzHHfEcjfrhzUNMIGFeQwd+vJvDzJOrctcXpcvHFi3ybNuok92qcE3nJVSY++xFNEApQ6sPmWZY03maeTxYv3CuyKiREh3WJznzzknDU3Ctn2cOYxHYLouW5hj9awrffzEflxDotM6U1rzz8ClRevtlWCZfYeeDnHxObAkShQIXz0h+qetvmBHn2/UiSQ9mEdIpUXZRFJGptjnSiT3646ZFM2kca2AdkCzdrbvEJTwvpfF/jDccHdYAm0wVylbazZmnL98hrNzcBgE1Y9SfKnGBadKjBFhwn4IdX1OfKcm3V9hIEJFMQ4HKDZIslD0FnWE3oO//LyZRkyIrjpCGee1DE+yYM/3Ug4nrix5n6Xm8MFgk6dxSrmPtnH1kqbyOqQ+y8SwRbEPp4g1rcm6d1J+fZjoAqxpBzrxzikFkOGbqekR3ts6d05fYYl13sHpZGGs3ymKYsqkHuTuB3HK1sinu9ndVUeZVOcBJHYw1nkFH7OCHxx+XWRY//SzjNEev1Nnp+d+D4eqZuz0JOa55qdwpu9uLVZA7N9hI788krW7kQWGRoEEyV52vhgEFiuqoFGVOzn8kqGfGSNGcF0B d10bkpiv bN8NOvwzGMF+bSYoAaijxGp/dSVeazYtxd9c250An8rauSYS6tvA5XVXEpxiGgh3Jc5LeFRRR/3r4WMba0SEEoGYli9hF/K1hcO5u1Um19NcQL6+1UixWpgmIX+G6r43DbmIibf1NueRvWrngfWRlU0oWTw== 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: Use local variable huge to check whether page is hugetlb page to avoid calling PageHuge() multiple times to save cpu cycles. PageHuge() will be stable while extra page refcnt is held. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 905758af70f3..88e48a4801ee 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2621,7 +2621,7 @@ static int soft_offline_in_use_page(struct page *page) } lock_page(page); - if (!PageHuge(page)) + if (!huge) wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); @@ -2630,7 +2630,7 @@ static int soft_offline_in_use_page(struct page *page) return 0; } - if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page)) + if (!huge && PageLRU(page) && !PageSwapCache(page)) /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages. From patchwork Sat Jul 8 08:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305632 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 73FB9EB64DA for ; Sat, 8 Jul 2023 08:57:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8E18D0008; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89DC58D0007; 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 67AA38D0006; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4D8A08D0005 for ; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2786640118 for ; Sat, 8 Jul 2023 08:57:38 +0000 (UTC) X-FDA: 80987841396.27.92B1408 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf01.hostedemail.com (Postfix) with ESMTP id BD52B40014 for ; Sat, 8 Jul 2023 08:57:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688806656; 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=sRPaYEQzZ3wDrly8cKtU5F8HxsL6XapCq9OMk94CHUQ=; b=JXYoEqyhiqhAej9N49TEyqQv9/Z2rJiXOyW8LNtWHD7iWdOSxN/8rkOllXKjBuj+KmXKlA HlI214PAPLIGVS2RVAa86CY72JaBos/7D2k6kcWFlZo2PteDVqwjP8ak5BDHS2szT0f8GP 3xDKXL7SxdUb6+CJ0uhpwAfqtgNIkxc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806656; a=rsa-sha256; cv=none; b=4bR+XC/8Gm4oJt3qlVxsuhMNYf8B67zVGKTF0nRALjnIIkwDAE2LquVWqR76UqpjXwPXYY KsiOkP7rBbj1RtF36eIa1E16eCPnp1WYQWaKT85Keb+kMXd5zc1rkOVaYoYDtwh7T0CUGn 2VP0yOsXfHFhRDaJ/Nvgrowsw2S3Gsc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QykcM0YymzPk0j; Sat, 8 Jul 2023 16:55:15 +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:30 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 5/8] mm: memory-failure: remove unneeded header files Date: Sat, 8 Jul 2023 16:57:41 +0800 Message-ID: <20230708085744.3599311-6-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-Rspamd-Queue-Id: BD52B40014 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: dz7i7gbmcje399ejsa7tja76wqqnsk7r X-HE-Tag: 1688806655-795572 X-HE-Meta: U2FsdGVkX190uedReKibyokso8L8lfGdUJ7Ncx3OgGDVRPjRbjxrcfXM8qfLwZMm7hz0X+nrjsTR/ZwbPcu25vPJBbqWZ1meYK0MahKgliijK7ovvQbY83BUDWbe9C/zE16iC2tPR4D1yGx9+ABW1o0xL35SzTwNPYXs2D2Nki+YeJqZLYQmKaptCXeyD0NHm6Y+Vage8dtCkZFsgf90uvFy5U9wKHYX9qQH9r5jZGAv8ch5WhYj3psB5AYkihipBX3oN5LiY057ZDTmkkW++jEqbSkyJL7ybNFqngVJFyPAgDqAfk4n6SxrQRyWi8KURD9K81axCiSOffXIZIZHba0FURR2YN0IfXpCs77H0iGuYdNCz/4E5t6KFyD7TzRqWHpiGqlvoELcRjOFsJH0ut9dWU//irAgl5rX54LfRBbSHmsUUJ/VrIf7AasL9dpXHxw/3+EIW1THnLbVSsfxTh+KbtE70jq7WNL7h0y2ygk1Lu1opsT7rZElFm8QAPhRzedF7IVosP07GbvXTYJSICF+x5QX6uzD4VDrXN+yBnl3NYsWQBxSMTZKM131pemchELI5/Tuwu9Le3dZk+qvIahXLa3PM/8eoIgKwJC674jeswD/KZZabGQ42yApz4Rk6ALY/UpWmuYThFtZPr+23R1TLEZgsk9V4EzBkLTbIVy7hlQLrwL+VeT3YsWZ6qJ/aav9JTK1DEtsP20eUISKOojGcetbogiVB/JJ/TeqSsW49imB73Ngiy9QKybwwHdzGtpyjvpSec4PpB8loTHlnb6Zs2Fvq0RyKq4+gngQ1yrZNJcx2RsFTJ55S1EttJKNcfAuHVYjVDAPfDVJgMO5JmWqfhnX94ZiN+HzJWLJ8etlTxD7wU+urHig+2TreTiV9IJFM3Ca3wS0WYigVjRZScxodB2g6drwX/tPyCqk6q0B9LRBPw24Cew+OJUeZX+zDJhGjmjC3TyPq4+90RW 2cwiwgSr M9iRtnTb3ENTLvekZbHtWDKtI9VqB/5O6F15us4yN3MM2FhOr1xz6VD7SPDDeM/0dARVFNOviGu7CJc+63Ku8xJcwVs9ly5h5Brk7Z9EZlwxJAMv2abFALc8vtvQKh/qKzpItIi/j/AP586Z2Lf+QBPnI6Q== 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: Remove some unneeded header files. No functional change intended. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 88e48a4801ee..601936f8d30b 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +57,6 @@ #include #include #include -#include #include #include #include From patchwork Sat Jul 8 08:57:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305637 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 2264DEB64DC for ; Sat, 8 Jul 2023 08:57:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD128D0007; Sat, 8 Jul 2023 04:57:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E67FF8E0001; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCFDE8E0002; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 835C38D0007 for ; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4593EAF690 for ; Sat, 8 Jul 2023 08:57:39 +0000 (UTC) X-FDA: 80987841438.20.88385D2 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id E8AAE80006 for ; Sat, 8 Jul 2023 08:57:36 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688806657; 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=SdGpbb556DGksW+H1uvavfz+poJOo1vWJOFJPx6ylv4=; b=opVI7exxon6S0CSFal5kzhvM/8Gb1HYN3GdV0aWSkmaBOSCRwa45oZmtkP5b+3dRU7rWeI PeZun9EuJcu5ukeUT8SwNmFrK+GLQAEIzXFa7SSSeuNxthdGFCS8W18iW4cG8jENoDpi6Z tMCPLdpYC08CJ9iDJGRNQq38QRbxvCc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806657; a=rsa-sha256; cv=none; b=ixZZGsIBQgskGenxBRh8UsbhU0FHrH0eQIzwJqhgqZgmxHZrkHH191y25iNniBCYesXjW9 aFhWE5eGrC3nfKTGhd3BGHijdjCkV3iZy2fUBhy5Ydhc9BAEbsVKO+hLJG0cz4quXAPUCp UF5GbdDySj60yES/Bi+2vZFJEDDCr5M= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Qykdh22YNzTm2M; Sat, 8 Jul 2023 16:56:24 +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:30 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 6/8] mm: memory-failure: minor cleanup for comments and codestyle Date: Sat, 8 Jul 2023 16:57:42 +0800 Message-ID: <20230708085744.3599311-7-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-Rspamd-Queue-Id: E8AAE80006 X-Rspam-User: X-Stat-Signature: 6ib84656aqhwiedehn9ghcyjenxa6syx X-Rspamd-Server: rspam03 X-HE-Tag: 1688806656-888780 X-HE-Meta: U2FsdGVkX1/ocZijmpX11rC5NSTGSZAbt/5DH+3GkEoJkF6NTthuYP0SnJsM3ZXEHEP6wrHXM6Uj9iuYFNlYxiYcNr3JuiOF1Wtf5L8gesI+z0jV/tb6paXwjkFXJjhxfXo7TSsVhWORwP27qoVbTnJux46TQEzv/UMwM1F9OJhpntHZt53GN9GV7dMI8mNFmrKXBMVf/9PH7yMzI7AkL4iavhusn22Wz7ubWr7Ix6iHOykSiKGUx6KeUOwZxzpbodvUDqWTYt562xlsFEpigZFIJwD8l3KgHfEFQiIZzOeQ8FyjmMe9jUoOXfkx2m3FT52asW6WxmOzAwxwD+OfYlBYPekZKIpKAmLx/kGRuSg33PQi3ZTHGURlx1wNWSbw2PYu7mywQDD0CG47EAuoCaiNh+zzucZh/0+5VN3KxVLEEax868lqTkwlDgCtoSJYIWC7GIl0HmlOdbitt3xe72pAgfBePOAYV+dbHHWJvEi9g9UGvSeJPycHlGWfKuKxMJQsiiuA5FtLU0gJHDtL3s3xgthr+nbd4S5UV9ofLvxc5MOwytp9KfJ2bmePjQOjZBU8HM9DvE0yn2SsTBZFMVceRQsr2izpXxszrZAL/pUe45vY96wmnYqRBDmbYWs52ORltvOfKqLJIiwOH2Co81MUDxmzL5DNRC++5WST7mecu9g/Jg6AEfbjv3KxM8XjS6CvsLLnH+j6wYma7JO+vBd60/M7PToubuauVLfhg2+miaUxPL/BwYCfpzTdLCH/9lX7LdPt9DANZ5Z0W4a8O6+s/nlJMxQIBfh7b3MR3Rob/zd79iotYTWQNcA/WKGpvrqnBYKN2iystOBW2asL4yM3AYyYj2o7KKrs03/A9KSkvfG6VL9FQH7i4myV5fk0yJq4K6i+2lM/slez103mAaNoUo5C9RSdCPlmp99CRA40FhH8DhkNPnz6iwdMPJIgnvAvFl0fD14Jck9kINs llbbq3O0 yGBZ/fT6sVelDoEphF8na4YrAUumLwsBTwYUjGtpXyGsh7tAfA3FSnWS30/4PGVtrNVE/Bpn7gfKAmyseZpjWlCyeOK2mkDDFvdIOMea2bkcYWt4TrhW4u8OazIGT8Crn/Q9Nv+rNjrX2ZZg= 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: Fix some wrong function names and grammar error in comments. Also remove unneeded space after for_each_process. No functional change intended. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 601936f8d30b..0f93175ed862 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -608,7 +608,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, pgoff = page_to_pgoff(page); read_lock(&tasklist_lock); - for_each_process (tsk) { + for_each_process(tsk) { struct anon_vma_chain *vmac; struct task_struct *t = task_early_kill(tsk, force_early); @@ -652,7 +652,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, /* * Send early kill signal to tasks where a vma covers * the page but the corrupted page is not necessarily - * mapped it in its pte. + * mapped in its pte. * Assume applications who requested early kill want * to be informed of all such data corruptions. */ @@ -2120,7 +2120,7 @@ static DEFINE_MUTEX(mf_mutex); * detected by a background scrubber) * * Must run in process context (e.g. a work queue) with interrupts - * enabled and no spinlocks hold. + * enabled and no spinlocks held. * * Return: 0 for successfully handled the memory error, * -EOPNOTSUPP for hwpoison_filter() filtered the error event, @@ -2225,7 +2225,7 @@ int memory_failure(unsigned long pfn, int flags) * otherwise it may race with THP split. * And the flag can't be set in get_hwpoison_page() since * it is called by soft offline too and it is just called - * for !MF_COUNT_INCREASE. So here seems to be the best + * for !MF_COUNT_INCREASED. So here seems to be the best * place. * * Don't need care about the above error handling paths for @@ -2582,10 +2582,10 @@ static bool isolate_page(struct page *page, struct list_head *pagelist) /* * If we succeed to isolate the page, we grabbed another refcount on - * the page, so we can safely drop the one we got from get_any_pages(). + * the page, so we can safely drop the one we got from get_any_page(). * If we failed to isolate the page, it means that we cannot go further * and we will return an error, so drop the reference we got from - * get_any_pages() as well. + * get_any_page() as well. */ put_page(page); return isolated; From patchwork Sat Jul 8 08:57:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305636 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 6E24FEB64DA for ; Sat, 8 Jul 2023 08:57:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 048B18D0006; Sat, 8 Jul 2023 04:57:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE0CE8E0003; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABD7B8E0001; Sat, 8 Jul 2023 04:57:39 -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 886678D0009 for ; Sat, 8 Jul 2023 04:57:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5D9C6120141 for ; Sat, 8 Jul 2023 08:57:39 +0000 (UTC) X-FDA: 80987841438.18.377C193 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 2AB4B40009 for ; Sat, 8 Jul 2023 08:57:36 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1688806657; 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=4zvreph+WtV4FNPz7Sph1CKBbIMj5dh6CNbYbbIKYXM=; b=mOSKJxQjMiFmo0xepBU3lNhIEVqDh/tNDfWPXOcCwUko7ZQfUQ/0yGR8gB/0MGgrbdWp8e T40K8JdoHMKoCn8Vdfp36Zkjqfx0UuKS0+IJhMlAF2gIzJfYhLFRyE1oJ5VYvxebNiCzrO RIMgZJRet/8T8CI94OG0/fG12l5uVz4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806657; a=rsa-sha256; cv=none; b=Iv+XuU6XYqsXIJZMo8edgxIG7Pu2VsD1K2u1X9LE7p2VebaANk2ry1XCH7RT1KyIx0uJtC HbF/rG/692YayqMn4dpmASteCG65BYSy5T7oPmFulJfloiEgnJBKpLfOVk17Em0mWNcPIm 4hC89ZKIKsowSfkOeoxERLDjWgzamzY= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qykbc53xHztQnv; Sat, 8 Jul 2023 16:54:36 +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:31 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 7/8] mm: memory-failure: fetch compound head after extra page refcnt is held Date: Sat, 8 Jul 2023 16:57:43 +0800 Message-ID: <20230708085744.3599311-8-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2AB4B40009 X-Stat-Signature: etey6dagg7x943ymijkrdwh96haqjofi X-HE-Tag: 1688806656-29082 X-HE-Meta: U2FsdGVkX1/zAp3mRB1IS2RQveL0eZ367RLK4dilwpuswuEwdl9ok2Zv4gVc+Ixwb46G1m/bi0cRkKegx5ZIAXuKkZmpPSw00wTzZwxIeRPWjKWOlfVSqeiX3zgDTTOqKxjIiDgXRyPOV6ziHyCbax1PGHO8adT5vMat/cyJALQDMnLBI7xbVbAEaJGwCte86YICayzKzfvt4GwMicCqZBBd9rXv1BsuF997ZVzdy1dfeikr7u5DrKe4fJ6PnALC+ve7O0vpCka9lZWrUzUCOJben+bsDgL+N811aEGMlePRCb5ohUHfiX5xxmJJatM7fSMLDLs45kkBvlSrLJnxpmBqdDkPCOAbdgKle6hyZ23jOq1hFA++uPex3T+gJEifw4kgwDrH81FpoB9PEycmj5inzV2z7Nyx3w7hpU81+B6a4RqE6Wv2KuD5SqdVhCrY1Ibuc2iMKvMpRDqj4uo2pU27/lKwEXExxI0R/QDIPP7e7XSpmfsr/vOjCTPkPiNhreKuGRxzQTVMC+IPggfdHyEGPuyYT7lp34n9zzhezJLZPWL4/EyXMgwK2iQYL4ie9kMSak6GSdQ4lZS7wBAal3IEzTmk93u7xmQOWuLsCzdjFLCO/ntZYq/bmuyi1g/ozXjZfBgoYTkjg0ZfQNceFMR46oE7b1eLAZBXhZjpVUNpKwXgTbJf5zALbNKMjrcDBdGDiMWZU9/7KdBccMcsXZHaEWsCwbgyo107dyaaXB/lWDrnKDzeqaPnnzhtzkgrmoyq18+rrLSG98yqMiHlL1M0onOGjk/O3tNmjfGO6vrUsqicMDHcNLXQyp6QT9WBpfpzxqn2tUdecXtMWuwnTybEwNtoeSsw/DKs2H8/gmqBSuKvZfZMUw9pvayXlMUNK9KfGa5BEesH1meMvn9g2+LnKMu09HLaNC/iFVEtKwXkU9b0jCb090cnuwZyzGgP3E1nUCLN1khZzCO4VyH 5i+61kiF HNTu5qUPWH4/mgX2WDIjijtcrmJh0fYT5wTIBE8aTjFSX7SAx2Y4vW4rCnTD9Kt4Vfwju5d7HR7NY9sK/dE8fh6wLXqBpZTXlzBJU2maSrJBu5XRHy5ccd5mDwKg+jEuIbKRevvv4/dWxr6U= 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: Page might become thp, huge page or being splited after compound head is fetched but before page refcnt is bumped. So hpage might be a tail page leading to VM_BUG_ON_PAGE(PageTail(page)) in PageTransHuge(). Fixes: 415c64c1453a ("mm/memory-failure: split thp earlier in memory error handling") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0f93175ed862..76d88d27cdbe 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2179,8 +2179,6 @@ int memory_failure(unsigned long pfn, int flags) goto unlock_mutex; } - hpage = compound_head(p); - /* * We need/can do nothing about count=0 pages. * 1) it's a free page, and therefore in safe hand: @@ -2219,6 +2217,7 @@ int memory_failure(unsigned long pfn, int flags) } } + hpage = compound_head(p); if (PageTransHuge(hpage)) { /* * The flag must be set after the refcount is bumped From patchwork Sat Jul 8 08:57:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305633 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 59A28EB64DC for ; Sat, 8 Jul 2023 08:57:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD7D48D0005; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D5AD8D0006; 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 78A918D0005; 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 5BDA58D0002 for ; Sat, 8 Jul 2023 04:57:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 36EAF16013C for ; Sat, 8 Jul 2023 08:57:38 +0000 (UTC) X-FDA: 80987841396.27.E1B4B87 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf03.hostedemail.com (Postfix) with ESMTP id E5A8D2000B for ; Sat, 8 Jul 2023 08:57:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 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=1688806656; 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=Qv7v0MakVggbJJx0U+5+eQj6+hfyeFZeeQvIWRA1lsE=; b=tS2jFwnCCIPhfwyVqilaqclMNK2ST5+rDJT7ZilPDeBHoVoGgFdxcksMETYIXnR/Ng2Ppj JgHvMDbAISJJ1ORijTVDtBqeSJ8GUgLxtM6QN0iOtHO9PO9hBgljxGMVqDRNJaCJVvcayE y7oIjTm4XpGGZwhi3iSapyk4VlI0TsQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688806656; a=rsa-sha256; cv=none; b=TT3wDWXeZbTm89wT+nlrbsqa7DEQM47QNEh8TCyE1wU2cGuh2FiCV37i2Tlce/PctI18tV 0pDCFRBmigOcLI+f4mw2etAusXE6kci5CjARugX2xcikCDhfs2ca9/0ILuKaz5XKd9EwSh 8jg4z57uIH/YOtIT/sFvsuNgkWChd1k= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QykfQ5qvgz1FDgw; Sat, 8 Jul 2023 16:57:02 +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:31 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 8/8] mm: memory-failure: fix race window when trying to get hugetlb folio Date: Sat, 8 Jul 2023 16:57:44 +0800 Message-ID: <20230708085744.3599311-9-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E5A8D2000B X-Stat-Signature: r9ho5d8sazk5jpkjak8uw7696fdoik6r X-Rspam-User: X-HE-Tag: 1688806655-639610 X-HE-Meta: U2FsdGVkX1+jfjBcUvlwRwHJaIsfi9qaqC96Z3mDBVC3uSMGoMDCBzq26PLYbf3a8lNziOkmJSy7MNS1nwkZ+XUoZ//1HMTjiWFv1P+Uj6E6ubPnU1ASGe7dp1L9wqBll4KUPO/WbkG0WCH2rSNnXPTlQdrbGYDulkYJyLKIpQhYLthUPemlZJmwGJ/S9VqM2DFa82uQ6itagD1T2SlYOHXs0r6nK+lcpHS93mkYLoO622DP9+3dNZ4HuV8xA0Gu8W3l284pm6LsbA5tsv418Gs2CsV3O8XcC4C3Z2okDeMqSui6paKcHssxLL2tL3HDFdb3tQPslhVU3aYAqU5PnvENCR83mcng1JHuKj4P3jwreMFSPE4UVK5e+BWbhvE9nYizVu6QwVAfwFLOkbC2PuJNWoSde45FjQeWyAP/zZCQW3eZufoe6cfvqTxL7ub8QDoiuDRb8QXntuWZ0CuZsTXp1ggtU6tABELbZy646c1LCblOHK4QihAcjZn5Lk3A/W4VtN77UXLDwUX73UfoI5KQAz6h1aluxAwRBvjZL/+vKZBL4XS2Y/kmcsCpZc1IAaNPi1eKUkGT48lCF+vFVkxEaklE6/WrP/6pc6II9Jw8iC2ppKqBA7jRg21BwM5Mqjv5xO5CUGLZhAlbBEx1Xe4b7mz8Md7WNdSe1tw10GSKB3h6Am6POzHB8Ifs5WmimKD0OfEPSICMOWTDfAV0p8k8ti6KTgtWPS+EZxqkUQYqgv8WF/etNJYzPwh9z3MRnWLpdN8AiPvbeKCmbP5BFyEk+pQn0bdD8Utq0soPD+K9m1BQCSFlW/wP2mBNY5XpSH7Tfzw8WsycojxHl4eIxt/YdlIroxdMk7xa4CHfDIF+qYouO14jQNFgUyd/b72UNaucGHAK/Ar5G4tEa4BN8b4gvJURXIEWGsD06vbY7FzqoSUgDRfvrGutpCKSXnt4RIQ3RX+siJ9CFDnClkh h5C2s18L TNB3DFiWThZFAbaxy2odQ+GyfR9Nxpyedk4AvbNrwX50nvhAqtzu5oJ+s1lzBlE988jyg4nCsOfOvq20CVrnBywZZux6H65ECUejVbTW1N4OXMXuOnKBaiCiEp0PQCdtITqE7EzNWQBkIkKg= 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: page_folio() is fetched before calling get_hwpoison_hugetlb_folio() without hugetlb_lock being held. So hugetlb page could be demoted before get_hwpoison_hugetlb_folio() holding hugetlb_lock but after page_folio() is fetched. So get_hwpoison_hugetlb_folio() will hold unexpected extra refcnt of hugetlb folio while leaving demoted page un-refcnted. Fixes: 25182f05ffed ("mm,hwpoison: fix race with hugetlb page allocation") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 76d88d27cdbe..066bf57f2d22 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1388,8 +1388,14 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags) bool hugetlb = false; ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false); - if (hugetlb) - return ret; + if (hugetlb) { + if (folio == page_folio(page)) + return ret; + if (ret > 0) { + folio_put(folio); + folio = page_folio(page); + } + } /* * This check prevents from calling folio_try_get() for any @@ -1478,8 +1484,12 @@ static int __get_unpoison_page(struct page *page) bool hugetlb = false; ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, true); - if (hugetlb) - return ret; + if (hugetlb) { + if (folio == page_folio(page)) + return ret; + if (ret > 0) + folio_put(folio); + } /* * PageHWPoisonTakenOff pages are not only marked as PG_hwpoison,