From patchwork Tue Jul 11 05:50:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308139 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 E77AFEB64DC for ; Tue, 11 Jul 2023 05:50:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E5508E0002; Tue, 11 Jul 2023 01:50:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC86E8E0006; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A81D58E0008; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 40C7F8E0005 for ; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0F19080123 for ; Tue, 11 Jul 2023 05:50:11 +0000 (UTC) X-FDA: 80998255422.17.E51D947 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf11.hostedemail.com (Postfix) with ESMTP id B650540005 for ; Tue, 11 Jul 2023 05:50:08 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1689054609; 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=LAkEVE24Qv+BBjIU19L5nrF8dLgTZ+0ofSIBY6kqzZM=; b=vscnAJf1YUasWWZeHcAn44iS9ZiVFDKRq2XveAM57iVhzytmoWPSuEBQZofmOPMVGy8IWH JlP+Zk32u5iidLyu+vn+DpV5bCjWuT0L+tLF2BasWyF+oNya8HsOHJy8M92xKyNaDeHiUL +jE8WHev4LU2UhGer+QJ5F/DNRNY6As= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689054609; a=rsa-sha256; cv=none; b=sDt9SPSZ9lIP62UqlSZdlK05+DNM1ofWKEcpVmOgiRH/U08BZY4OavGbwwqEWwJFJNJdo1 /QNhBBCA7/3irBsL+zYTfl/K8DqnZygML6m0B1q0HzqhUssa52iA0EWNyBezThJcf0VwNG BvtMILLq6sKkUcaQSfWoqKgjvYRO/uU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R0VLc1cl3zqSHf; Tue, 11 Jul 2023 13:49:28 +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; Tue, 11 Jul 2023 13:50:01 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 1/8] mm: memory-failure: remove unneeded PageHuge() check Date: Tue, 11 Jul 2023 13:50:09 +0800 Message-ID: <20230711055016.2286677-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: B650540005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: u93dausogz4wcmr1abh364hfajebqsaj X-HE-Tag: 1689054608-404715 X-HE-Meta: U2FsdGVkX1891ASlTqCDjkuDhD3JdyRuPMvJTM02kwr0vl+FX6OSBJTzv+7Hb3wxTqzrFf5qsEIgJpYddAGuH9S8M6wTMBw1UwbWT0tj8nNZoAFSSKzr2UzhblFxOmCn2staXqeNHl3QZ/Bs3NiEj+lf6ghiXBkYxCSZ0M6JpanecM7y4ycKj93lRMBWrkA9EYrVM2B20/U3vSwC/IYA8dif0vgHQlmWwKisexVH84BMl/RZdLdOiIMmFVnaAkc3iKv9W2jFX+mjuZjjf3wYtd/2R9UNEc1cMCXoCEgabuYvia+azu0Qq9DH+LNeP6szYxsLd5LFF5Tv1B2zdKM8Na3yhaXeUBRI9KsgygyyjOJXBhgeESNz4E8n0zgYmYyps3+8gxhKp1dpaH1hbmargiVy93kPowdQInuOAAH9Rq0I6E18Rwd9Rv05AzYZsAgtOYawZqVrrCID7hmXp7sF+87No7hcVZD429a4a4frXnWy8/tPLPa0MNMmT9W8Rvap6MWRrYi+AZUOiOGSURznmiAzIDXJj7XeRTGteRORxaN35CQsCN418GN0cl94wmc1JteiAecwmzbLU6B7ARQKatn/nvWvYEOewSa5DKuQYB2A/oeadCQR/cDTahUI3Zd8ra1DXB6k+YBzJs9DRRnLyso0WeKaLaDx1RDPUqTwQsTunzc6hhCzIL+ePRIWovx+dpW6umO+DQpFQZV6CkfGrD4HayE9aG7Y2lfIwDnYUwyF7z28aqqXig5096bKWgQJ95p7Cbfkcm0jqHHJcv6nItmlVue/E/R9ms/lGVxOUu54w667b2Lmj/A96DnHskvkfhuLE9cYDGUZ3TsExBoHVhUEFCnKi/3hQg+0rNY2Z+zVy8uN4gnt8v6TuzN+B8e3VsUsLEw2aiGsEmIW4SO85PR9eG6Hd69g7ejt6cWigOySx95iadvNVc0dh3TqG3LbawazyLoBnTJxIyUQArQ MdNvWFie JlpB5uCuRF5NhKK+34MiWV2Wy6/QyqOMzT3D3sVUHVhU1V7Vz3JQRPjL2UqmtyL/dvxOdNWd7AYv+brveDs3KK0OzHo0IEs95OPUjSncPtpWTUPt390tyTYgWrgwRkHlB7y+hK6LGuIolclY= 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: PageHuge() check in me_huge_page() is just for potential problems. Remove it as it's actually dead code and won't catch anything. 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 64d7d34c177a..913fcf02ad38 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1187,9 +1187,6 @@ static int me_huge_page(struct page_state *ps, struct page *p) struct address_space *mapping; bool extra_pins = false; - if (!PageHuge(hpage)) - return MF_DELAYED; - mapping = page_mapping(hpage); if (mapping) { res = truncate_error_page(hpage, page_to_pfn(p), mapping); From patchwork Tue Jul 11 05:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308136 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 E070EC001DF for ; Tue, 11 Jul 2023 05:50:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26C648D0003; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ABCE8E0003; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E4A8D0002; Tue, 11 Jul 2023 01:50:10 -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 AB0568E0003 for ; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6BC738010C for ; Tue, 11 Jul 2023 05:50:10 +0000 (UTC) X-FDA: 80998255380.22.F093003 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf08.hostedemail.com (Postfix) with ESMTP id 049F8160003 for ; Tue, 11 Jul 2023 05:50:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1689054608; 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=c3+4PRVCOc8lFGp+68fWiH4guLJbERi3j/h49cE9di0=; b=L5JC4BdJ11WKc166vcpypERYMij/DFyhW0ls8n2lbhE3EJyKp4iqoeAPZEd2PHawTXuqf3 WVdTmG5W5EAZUgNehreMkqvwua3zHqJ0TUo0epW9bTnDlc6dhOioA6kEyYyoFlUHNh/3Nd qf8JJiAzN4QfmwLX1rr/mxbxg0v7Mvg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1689054608; a=rsa-sha256; cv=none; b=5w510g+0oDwn77Rj4P/P8XxOGs9qPF5/b/uREx6RlNB+NZHe8PhXoMaKEYZJJO1WzKeCHT qSjGXmMhOnlpakRL3YME5M+q4BH1Fzd58hzVYikrzb+DbunJgbCvR0E75S88gXwKZgeT6g WOWaJoeeDHV7Z3JnFQ6ZDdAd49iu7iw= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R0VJb4QvVzPk2m; Tue, 11 Jul 2023 13:47:43 +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; Tue, 11 Jul 2023 13:50:02 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 2/8] mm: memory-failure: ensure moving HWPoison flag to the raw error pages Date: Tue, 11 Jul 2023 13:50:10 +0800 Message-ID: <20230711055016.2286677-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: ecf6wkr8cm7ujx7zydxa1j3i7yra3ump X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 049F8160003 X-HE-Tag: 1689054607-352977 X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C6cloWnXcWbhavMzsLr2Vk21RJuVCTW2ea5E8817FLmO73Vs5xjcgZuEbI0rEUSYmbuIJfoRpXCjVRFKzVrO/5gKZXw/2AFI4= 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 913fcf02ad38..feca3c4068a5 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1920,6 +1920,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 Tue Jul 11 05:50:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308142 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 6B8CEEB64DC for ; Tue, 11 Jul 2023 05:50:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE3AB8E0008; Tue, 11 Jul 2023 01:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1D468E0006; Tue, 11 Jul 2023 01:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9484A8E0008; Tue, 11 Jul 2023 01:50:13 -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 79F578E0006 for ; Tue, 11 Jul 2023 01:50:13 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 52DB5140129 for ; Tue, 11 Jul 2023 05:50:13 +0000 (UTC) X-FDA: 80998255506.06.450E20E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf20.hostedemail.com (Postfix) with ESMTP id 1E2711C0003 for ; Tue, 11 Jul 2023 05:50:10 +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.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689054611; a=rsa-sha256; cv=none; b=Zvc/dnchaQ+f8357BbiatatV26eBY6SqS3QUjMM4FdyfFFU1ID7V/fcsGxDzmGnb37qHgB sB7TPGz7+NNKM3wvQ2A4zEwv8lRNG0cls82zy2iSmzY/dhmzNh+SQJ4+uPAVtt8mijPc5u FQSAl9sSkNpQLTlZ00c1Ls9Gt4kOEcY= 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.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=1689054611; 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=rbVV6E6KX9xBwZyFWx2W1vSds59LeiPIy1pErc9efjo=; b=5TIaGTQzX8N0+p2rVuK56+NMfVRv02vaEB7bve2NYesaTaADWeERbQ+lZ2O+ROxg2Aj+GL a+/T+BjC29OGHWbPiC5orHufC8OC2cq8hk1+EE7NqWn29IR9x90D3ue4zSL7CLENxNTxXb mxsswuaU56fzidVJZEnoSJElT6i+V8s= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4R0VLd6GMlz1FDpF; Tue, 11 Jul 2023 13:49:29 +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; Tue, 11 Jul 2023 13:50:02 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 3/8] mm: memory-failure: Don't account hwpoison_filter() filtered pages Date: Tue, 11 Jul 2023 13:50:11 +0800 Message-ID: <20230711055016.2286677-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1E2711C0003 X-Stat-Signature: 45czpk7r7i4ua9nusibu869io9ctem94 X-Rspam-User: X-HE-Tag: 1689054610-131698 X-HE-Meta: U2FsdGVkX19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5nAMXTSNd3C4D846t4csM1aFKWrZZPj0cdDFYUu7/eWOlTs7+ixbiAFraqu7bhnZuar4usf4gKA22OFNxN6UOjPFmaPtpHbBXCELP8R9mKhcKoHtrlFoq2zoeQ2MtVaA== 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 feca3c4068a5..c80b7d9505d8 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2108,7 +2108,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 Tue Jul 11 05:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308134 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 4A515EB64DC for ; Tue, 11 Jul 2023 05:50:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E5C38E0001; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 946F98D0001; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 772808E0001; Tue, 11 Jul 2023 01:50:10 -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 62AB78D0002 for ; Tue, 11 Jul 2023 01:50:10 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1FA9CC011A for ; Tue, 11 Jul 2023 05:50:10 +0000 (UTC) X-FDA: 80998255380.21.4B63EB8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 5E336140005 for ; Tue, 11 Jul 2023 05:50:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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=1689054608; 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=gxGZdWW+Li8qkcIOgXs3wSne6UlcSLwoVWi8V/kJIQo=; b=GFSpiL5KPakvcKvhWlmk6ZhDugSZLXa3l2RXVZkD+OWkLZPoiu4KUnR/r8vVJRaMSbrkmf UDiuTyDdx/VAQiVJIVOd4jrgyFV8HWrDrddBSOQmBVLccLUiknTYpasVyQWA+i4F6kLlIC V7+K0nF+/OU8DJ7YfqN4lDRhlGumM+s= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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=1689054608; a=rsa-sha256; cv=none; b=dhR+hOM06j7ihYLGtCNQ1chplpzl1dvOASxyWLy8OkaUiaiJ//oCtfm+OPATwo24whzEdb K5v2Bn0bmOSjq7XLZ5MR9TWoceLK0KGmK5DjhEHGsK9xaYWmeXF91RRQ+XlZSwLnFt1Tep mm0M4xdHqGUuDPzAG+PNV1Zcd4npvqY= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R0VHV6bLdzMqSB; Tue, 11 Jul 2023 13:46:46 +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; Tue, 11 Jul 2023 13:50:02 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 4/8] mm: memory-failure: use local variable huge to check hugetlb page Date: Tue, 11 Jul 2023 13:50:12 +0800 Message-ID: <20230711055016.2286677-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5E336140005 X-Stat-Signature: rao5fmdadi1ywmxcu8xh9akcbusnyuwg X-Rspam-User: X-HE-Tag: 1689054606-407089 X-HE-Meta: U2FsdGVkX18thSU6FVPi+DTOpTUAgFY3vYn0m2woUdLDwQ5Y/Kppeaz3CZS8DvrlMX/dOh1Iw8+c6x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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 c80b7d9505d8..239e0711f832 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2628,7 +2628,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); @@ -2637,7 +2637,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 Tue Jul 11 05:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308137 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 9C8F0EB64DC for ; Tue, 11 Jul 2023 05:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EAE68E0007; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 688F88E0002; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5024D8E0006; Tue, 11 Jul 2023 01:50:11 -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 104C08E0002 for ; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D03BE160125 for ; Tue, 11 Jul 2023 05:50:10 +0000 (UTC) X-FDA: 80998255380.18.5B30C47 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf06.hostedemail.com (Postfix) with ESMTP id 5E494180010 for ; Tue, 11 Jul 2023 05:50:07 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1689054608; 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=2i79xieMi9enExQ9bAawHZrT03jaNr+fM2Du7WQiXQU=; b=0q8RXehFoAJZjXD8NnFYrK4Tqz/NMHAblpUE1Fa1ermcPLl6y4YhGfF0oBmeRvhIrK3nlQ svRoI9uh1uho25SY44J+1YmZuvMho9mWUnRrOCWv8iPf/wjGDDD/vs2unGqx3m5SkZU+jf r7bzpj/1GE7M0elV5j940cTyN/1c7Ok= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1689054608; a=rsa-sha256; cv=none; b=KsWRz2lK9zzJ9cS4HAhT2ZRefJImWs3gTlWGiF9j5uobghwVBrWAECH3c5y+DlYv9mpra8 NIDH+KsLUX/yCxYGU73XUzSOPCnQwyjcXDCgWNJKTGVuiZows8PLYkaqpJ88+FZQooRvIN a4e+8++AhmsJyAhxVE52JyKmBFIa8LA= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R0VLf0T5QzqVZY; Tue, 11 Jul 2023 13:49:30 +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; Tue, 11 Jul 2023 13:50:03 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 5/8] mm: memory-failure: remove unneeded header files Date: Tue, 11 Jul 2023 13:50:13 +0800 Message-ID: <20230711055016.2286677-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5E494180010 X-Stat-Signature: 7gfxmsqrcohnaz3cywohiea3bs1b9ehn X-Rspam-User: X-HE-Tag: 1689054607-599284 X-HE-Meta: U2FsdGVkX1/H2TIl78+z4dIWAjnOgmSe7Mdi3MJM6C9eYOj8+FcRwZ9Yfa6lVJxGqvgfIpXk+oAwcAtKyG9YTKGc05xcywrWkYzzVsSXvqwWzMtWawY9Ji6FiWl4yFSVPO1cKXq2BY1lRgGkbIvMrcBQqquIzr0m9x/TFmX+6y0cFloGnLCBzGOVV3htFr52Kq9g5qE8OLcjjGDt9fIS6ZWoGgY7K6nbb3SPM5XgZyYKD1+zDxJ5XOv0cmVXVmaqOqu0nAJAIe6kQQrBdLtRyuR29Xy19tSTM3sL8kt9BhcgXNnf8+lFvVv60jVFl0TWpDGV7xSJRFN1iXonZJb/Vn08SEx1qozMG5PE8XPoGNz6ubDcqgXB5ES2xW9zHI1HCr9cZCHZxW5quA98tz7SKXM9RMASoO1onl5FZOTqv+mrqCWNMI5O/Zhoo00zRqtnIGtTBtH3cU62Lke/Clsxsm9BXQhyoXhM1nMW14wx0YHH4XUPNylzCFDKS8n6Cy2+4fgTz5yvDrUhQWzcGm67HTKZdF9pQQ2yorQHXaz2BLm+gMfwDHk//FEHKSRLSI+ZIzQoo0A4ppqg8qugQZQdnkbtmn8EDZJPZmtr/NufTP+vXqNM3E4gwFcxUjMbDnhmVw209eZMoBt8EvMrKk/wE7VOflNz/bHfhnoChMebf5uy4T4SKTwTczSs3r/uuISQPqXgl6iLhbefHOcKgivvNNiXjT6g6Ak8hTPNrd/Oxty5wbB47vomI5tqyh4qZQ3nSnG4HRAdey1iFLO9rWLJh5rFPs5aIHVO7bfm7LJ8M2STx4zmjyEFBTIuvE5inbUlF3virbpUzoa6FIKvOL6Rk7AJ88R+b7K6y6ggWlauFWyNKscr3255fq2qbPgCN5a/zveP0i2TduVMDXM1FUKMwtOFS4j+CX6XuijbuKRhnNEm3m11F0qcr0kVL0SYZlzWkqh+Udh+mvI6XvSN4Ox zGfJDAU2 PPyOUkVp/2w5H4FMWTKrmZThWK+G0kLSnDgOUEEh+eHqPTgiF3gJ4uNFN/IojLEEGyyfxeD28G1cxgq4VVZ3zdrMov01nGCuVnhO2824cqEJ6ZGCgBzBDj1gOSYwn2hk8DmP4aZa/LR4KFZVcoDJz8s7CiyNpCdPrmgfPG0b/yWtccPo= 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 239e0711f832..0da6ddbdd718 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 Tue Jul 11 05:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308141 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 24AE8EB64DD for ; Tue, 11 Jul 2023 05:50:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4BC68E0009; Tue, 11 Jul 2023 01:50:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA76C8E0006; Tue, 11 Jul 2023 01:50:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 837718E0009; Tue, 11 Jul 2023 01:50:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5BE678E0006 for ; Tue, 11 Jul 2023 01:50:14 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3BD2CC010C for ; Tue, 11 Jul 2023 05:50:14 +0000 (UTC) X-FDA: 80998255548.02.9F2A5C6 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id 01FD040009 for ; Tue, 11 Jul 2023 05:50:11 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1689054612; 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=rtDDWy5lm1vMhjdZV6LLpaDKXMrheUjre6SI2saWdQs=; b=QINFfib0yu96RpGtxim7MAzNJ9obQqWKOB5CkEY4sZu4kZodwzJOG6BXupoFG/zn+m9MhT BHTt7PtGttH1W2uEMuPX1LpTthJFWCISb4Vl++28kUnsEFOP3+ZbkIEZOSDypJuQ7TrxZb qK+pzTIgh8JQya0LLSpE6FADtEM3Zfs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1689054612; a=rsa-sha256; cv=none; b=T6SY+wvGwEmvpk5RN47Z/MQUiMoDtpJmL/OJPrMo1gdn2m0i5cSnXSUhdqxB7IMkozwKVy EYrqVBRL+/+yeMS0cMMXGMyPx4vbgAcxK3jojy1Osz5XSDd1FRkB0/+tWaWctA7R8NXNGb l1f3k7jfgtKMB3R57gzT5tVAxJxgJ+A= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R0VHt1MsqztQvN; Tue, 11 Jul 2023 13:47:06 +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; Tue, 11 Jul 2023 13:50:03 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 6/8] mm: memory-failure: minor cleanup for comments and codestyle Date: Tue, 11 Jul 2023 13:50:14 +0800 Message-ID: <20230711055016.2286677-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 01FD040009 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bpkjnegje4i9h6588p4q89ngikt9a5ut X-HE-Tag: 1689054611-313066 X-HE-Meta: U2FsdGVkX1+f740MZVaEpHDB5bbW2i2NPpjpMamNqKZw2+sTEZ0Nl7362j5FNQYW17RrYWjYK1sw6X5m5U1O5qn+RiuiygL8QvRE6MUT5wS/nwjgziLXk2jPfm+bhUDtuK8/eou2CleM4UOmmYZm2AZDb60Z3tBgcln8iXj21mTH4fVmfH46brZu39xL37MAYZcVXEn5Rwct5sBuTi4Qcl/N/R6eevKnx6YoA10EyNkeOY1vGsE1ZrrvHb5CX7KWQ++Amm8l3QQTSWnCFL5Ij5EAu2tL+Se4ZeFKX9bh7sAmybqnKw1ByzYo4zL8uKHc4slx1eISlSCQM/rPXeuhaVqgt8ene8PRRBCoLV0n/unzD20aOFEc84em8y9JNOqK3csThyVigXFu72LneSYLNxlMwvDQpVcGduDgUZ9S8nee1GhX5XXnAH2x8U+P2X3q/++ywz/3LmByANe+j6XrK9mVzvO59cqrR0T1LHvsnIKuKxBx3nRQz6efPkfJ+gljJqYkhFMrq6+gZdVinOUJlGfwCd4FSxiqM6dOK6eAVQAcw61by2mlp0wIti2FB8W2n5u9+r7SY3Za+HP710yh5iBbHZy/tUnIvDJLUp8aWBI2KbnfvBv/Xmlk+Z+MIZQf4HTzeXzH+fLpQmpB4yI7JTwu+gKCq0GF5NRZ/ObLTmCGCOlNFJUORUaGvD3vKAtXJfTtRQLj6xBU0ATosDTJoV2+0IiE/PNclJWurounq4T1MQlZX1xrnSWjem42Zg+DFwt5pCAGgpEW+1xZMjyC6CbS9H8IQVzD6iXkmrbJaHa91j9IrNxxATFwDmarjgP8MVyA+Frq1jz0+SpkBJSiMiqOgZorIxy1x6AB7iJFNfkQFq2v6qnZqlcgYvUTW+39ypNYP3Qqs/FQvJ2HVzb8UjHX51lwnZAXJ+gmqnHcS7OX0kifzhKuV2A9WCPf0YtVKpOBjfYJTHguVWJGgKO 9D5PTyvm HrnSAXzMbruNgNLd5W8jPShPdAj4dQRO9HNX/QPdZX0RWZz9LSrq2ZoH3XZz9xhaNbT1Gpn/MSbWGqmlu+SecdWAqZqbTMMZviXmsUBEjfOtwODEeYnU6JIIWu3CXaRnIDKV9pCM8+lABXfMelUnqZDtuGTkDh9H+bntgHSbK63FBQGE= 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 0da6ddbdd718..db4c530944d6 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. */ @@ -2127,7 +2127,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, @@ -2232,7 +2232,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 @@ -2589,10 +2589,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 Tue Jul 11 05:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308140 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 6E70CC001DE for ; Tue, 11 Jul 2023 05:50:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 556B38E0003; Tue, 11 Jul 2023 01:50:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2716B8E0008; Tue, 11 Jul 2023 01:50:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D67E98E0002; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6F4658E0003 for ; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3A283AF6A2 for ; Tue, 11 Jul 2023 05:50:11 +0000 (UTC) X-FDA: 80998255422.16.545960B Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf18.hostedemail.com (Postfix) with ESMTP id E689D1C0008 for ; Tue, 11 Jul 2023 05:50:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.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=1689054609; 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=IV0T4/Lz70cuW+hklOvSGRAWozfHSplI/Flw5cVKpWk=; b=F5jug5Mt666/0yMwQEAa4AdPmOwIaB2NP7wdvVFs0zrVFU+MsK/euJ8GMc1KlCFw4l7cAw b7xBIhcY2mL3+Y0FfIqABUsAT3oD5emQaXVimL1C0Qo7vFOlbg26bt3jIT4g5XFcYfkJ6R JKHmGCvC0XVdY2sOvYlWbKNHQIEeZIs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.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=1689054609; a=rsa-sha256; cv=none; b=n6KUsfXroceXkOgiIZKjnEZxxsXYraxGIRVW4fCNCv8/ZhJvtt7+j7sP9NmPV/iSACyAKE lRufA9FbM9qCC8q/o7+01+JeBsoT7ZbW29/W3cntmHSvVx3P3L8UzjQ76nzmF+kLuVh/QI ueuWM8IHggS5EcMhqgoE8C3uhHzpYyQ= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R0VJd66LkzPk1v; Tue, 11 Jul 2023 13:47:45 +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; Tue, 11 Jul 2023 13:50:04 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 7/8] mm: memory-failure: fetch compound head after extra page refcnt is held Date: Tue, 11 Jul 2023 13:50:15 +0800 Message-ID: <20230711055016.2286677-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E689D1C0008 X-Stat-Signature: 3ktknfu8onhuu4bpubcyq1bwmhq45haz X-HE-Tag: 1689054608-193572 X-HE-Meta: U2FsdGVkX197GITUB9qTufTHB2FhYhu/GbbJH8pCNXno51P2Zt5ILDKOa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yVXxEis8YEweEBuSsykBxaYRszQ6o= 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 db4c530944d6..af34fd4669d3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2186,8 +2186,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: @@ -2226,6 +2224,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 Tue Jul 11 05:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13308138 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 EE65BEB64DD for ; Tue, 11 Jul 2023 05:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC8608E0005; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E030B8E0003; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E82C8E0006; Tue, 11 Jul 2023 01:50:11 -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 1B4188D0002 for ; Tue, 11 Jul 2023 01:50:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E6A9A40002 for ; Tue, 11 Jul 2023 05:50:10 +0000 (UTC) X-FDA: 80998255380.18.4A8BA58 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf15.hostedemail.com (Postfix) with ESMTP id 5FA5CA000E for ; Tue, 11 Jul 2023 05:50:07 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1689054608; a=rsa-sha256; cv=none; b=5f3b119Sg+rqYGi+m6N6Zzh5BfAARMlJx8J0FqdGPqmey05ksrgNl0veyn+tBUfBGgY1UO 1J1XyYa7fC90P0JSP28qdmt7SJPtbSLHh5h128P/c5CQR6nnCwZYYrCMEsvU/6FfAILHpp Xa4PsAuHTnTRiwwR4t6q+cUI4MTS2kY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1689054608; 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=kZxpc3LLQdKRwi1qZzsu5rtB5wD/2h93r2whajVTytA=; b=fkgT7WlHjfqlYCe3B/5mmvO6iUayixPJq8gMoQcCrfwEAva14FUDSoKbf1yHgbcLpiXj6x nJAWbFgPcLZSMqIdlXpg7+2BrVJL3S6lJn1eW6xFB/s6lfnPKjPXao5roYixP9aTftpX8R rk7zZoEiyHTicbWyHiUqo+V9rWQOiYc= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R0VHv0DmQztR5C; Tue, 11 Jul 2023 13:47:07 +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; Tue, 11 Jul 2023 13:50:04 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 8/8] mm: memory-failure: fix race window when trying to get hugetlb folio Date: Tue, 11 Jul 2023 13:50:16 +0800 Message-ID: <20230711055016.2286677-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230711055016.2286677-1-linmiaohe@huawei.com> References: <20230711055016.2286677-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5FA5CA000E X-Stat-Signature: g3ihzusrzk38tfqfgqaub4gcofp93p35 X-HE-Tag: 1689054607-985031 X-HE-Meta: U2FsdGVkX1+BMAj3+ttkjXRgDNbI2hL9lV/BN3gRvZLyNlEsW6cu2QyExkbkKzHIhUovSGV8KRDoyl8YV4G0vUQo+gJQae0X4mEmcs/FnK22CGbpQeSzqjfNA3Y5txDVulWOd4TY9zQ0Yz4jGzE/9rBZoOYrdmyRGnfSnR66YU/pWh+mlJeLPY/2Tm3FXUvdbIKSdM3MFYBqcslqDSQfBeEhbSlXYP86WMI2AXxz4i3DkVZZPaQH8RHXnKh4za3uV6NIL+MNyTGkaF+0hB/SNiC3Ii07YjalR3uBWajbnzwubSsyt7udOXHSKX9q3m2cevCO/VD8WJC217XrB9NY1VqtPO0Qh5C3TFh0b/OWXb0b2uG3fTxVc649bupw5dCsrAzveP//tuM8IBotvpgVVUofx69wWtYXgePLOWyQ+zf7zArhLMzl00yFGqgMaFvpqfhA+T43FkxuW+hPOUgtu952ivGrBlIBy9xRfYFmLfpl5aW3hua2wrgetVlVeva73BmWQKKaMHk+fiGdmgWOQd35hMtc4UUldPXl/R0fULKSjjL3l4m936Tdl+aNz3n4vdXtxq5WY0XELeRGr6s7h9CRmm7MtD8I3oGbie37apYkX5FnuT/Zfqjc97Xun63DsNPmpwBrVyEKAqC/QpoEAxvv0dsBpXYfEoIXb3QecNm92eAk88RmrhTqbAOi+fC7iSNIhZoaMqytYzXHN8e8h+Iv1pU9hrHzOsCthnZY6WG/KNlwuuKYYfqAVPVzjXl3lCPSTZ0zuS8Qjzu9cyPpEL24n6qXDNSiTtCYB3BbhpWJpqsodv3fGyxQpcSbFNdcJeSIyHGazIDeXJMCNDnCoDxZPb91HE65edbF6ReaYOdsr5R65OE0CJTmXZFsbUor52UcpaxqiaieHqxLNpR+G4sD+2100FQ/i0jdSX1ol7zhbFQ05l0/Sc89MFptplpTnn9TgHKWi++ctpWl7le iabKKgSi MOazzqCdpbCtPAn8zejnKtVeKwt9fj/Tle18lcIF1TKsvvfEnPD9eGa+TiUX4U/rluJlbGt/D/SYMTdc50lq0hK6KXY8PLIwX7mABx5zXNyUMkLROWtdEp6nQAJ7pr0wANOwqvPsAtkaganaE5Gn5ivfxpsqh4cZFaVjaVkf0c2xPK3Y= 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 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index af34fd4669d3..9ab97016877e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1383,8 +1383,15 @@ 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) { + /* Make sure hugetlb demotion did not happen from under us. */ + 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 @@ -1473,8 +1480,13 @@ 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) { + /* Make sure hugetlb demotion did not happen from under us. */ + if (folio == page_folio(page)) + return ret; + if (ret > 0) + folio_put(folio); + } /* * PageHWPoisonTakenOff pages are not only marked as PG_hwpoison,