From patchwork Sat Jul 15 03:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314365 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 A0A39C001DC for ; Sat, 15 Jul 2023 03:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E78E6B0072; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 021236B0074; Fri, 14 Jul 2023 23:17:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2C106B0075; Fri, 14 Jul 2023 23:17:26 -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 D27B96B0072 for ; Fri, 14 Jul 2023 23:17:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9D4BB803FB for ; Sat, 15 Jul 2023 03:17:26 +0000 (UTC) X-FDA: 81012385692.18.6FD900C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id 272E4C0006 for ; Sat, 15 Jul 2023 03:17:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1689391044; 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=iNQXzd4KrKutBsaSbfiDpnDpOW4z1ROINKZ0mOvwm/U=; b=WPg2/LGQFE9QvjiAYCQ3HaAUOZxkLNxzXlDYQ7jpJXV6wgOA1jrX3JMg3+56i+cmSGHqJQ wYawIUA3rtlZCJCApEF7D4V/Kg4KjEJj1aCuLJ20nZK1IJkQOXNIki79+CUmrgBAQLMjqE eOFaS4n84Mq/YuQElLjA1e1A0qCbEz8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1689391044; a=rsa-sha256; cv=none; b=uL1hENKbn7p/Eb6EEELY3cN0PAHROvBuKbaAZOJFpA4l9zGm0mFGkZ8mU70SrhrvxVY1IR EULhdqqUMSpLo0VCejluuOa0Qz+zlkhtMMb67WRwRp1pJsUS2QMTnGUeg2jyU5X4vNG0yy aqDqxQ/7cHbWVw7wkf6DT/qKBB+4BgM= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2tjQ0L4lzNm6c; Sat, 15 Jul 2023 11:14: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, 15 Jul 2023 11:17:19 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 1/4] mm/swapfile: fix wrong swap entry type for hwpoisoned swapcache page Date: Sat, 15 Jul 2023 11:17:26 +0800 Message-ID: <20230715031729.2420338-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-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: 272E4C0006 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sf194xjqtix44z9m71zs74xyebb1tuh1 X-HE-Tag: 1689391043-123789 X-HE-Meta: U2FsdGVkX1+1erhli6KTe9n4C178ssbYORQDnS2HRRxAF1p3ZnMbyGlW3eUCIOTQuT0sos4ruRL/VaGurOi4TA7kLg12EBhO5I5KqZ0XE59LJ1LYoAjphY+q8/aI3H2IrUzWYluUMt49qAUUmPIWwbtsXXR8HH+8Fd7DX6NlVNJVST7sodB8E6p6kVq7OKOib/sv8HugYGGkGRf3BFt+sCdRW76qR1rE65uCttVjnqi+sO5nYCrozk8zhjn4YTJ19M6TwHy9LA8c17ujHnoL8hyyh80uIQ4iOq2341ZO2PQ3xE+DxmcgbTaCjdWPJ4tXN77Q22If52DzPgIIAfh8RVhfU37EFc2rLTOyovAJK2k9MceKLWIC4IHP/WOPqftKB/gHwJ6xkDjJdwquOjR+2ZG9NmwNnY0DthOiUjEYCoZM8e0ZC4IYF5jbRq3ooHRuEOgSYKlSdlPNPddgYLRs5mOTnCJUbu0nNO8xn8VPEjIlyplUN88r8pZmf+ohY/rdO2IuV9uprXGbPFNi2nNcyGFbLD5/I2x5QMgmylHX/rLsTLjUYwp6hJtiXjld4cJxkOozxiKcj5WAFJAMvt1w0W/YLevCdu5Ojg0l1MUKGQaHJYIm+K2ooV5iYmMSGrR6uehoN5/3H3JkGTTaw5eMEgG+hfS0X+hId3klgoUClPO6Zc43DpyiOOoWEIhcASijUHpjzIa2s0lcpADUZatM9L0prXVOMG3UQgbBV14Wm6yHqbQRapNAnSbv7PoQDWehOAthg3BfxfS5SdibGEdYnObg3UgNjLZ+zEHBlLY6BtxHNrBoHfH2fez0W89K6FzyzfU39LECXNH1yhPMtaZYEHUmkrUZoIVTA9cbOF/4Gvng7hJc9TkACAINHba6AKmcRLMXXJBAPcdxDW4tPZGYKaGVj3fD6wT4L968V1m+vEQaJhxUtC5ah/Q9F7U2AYTtvKGHN+mvTtvk1dw/4HA J199VtGh Mb2P6elQiw2R11CRyLy9D6vJe2UEdoXqnHWYVr/JdCQKoe1DJUy5gTtj7nztwBnLXp5NjEo5hvD26AoirOVmZMQLAMRNffzhAK14EGY5ndlFUYuE3zNjMQfaWbYCD7Q1Lfx8vHEhNw9SIuIU= 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: Hwpoisoned dirty swap cache page is kept in the swap cache and there's simple interception code in do_swap_page() to catch it. But when trying to swapoff, unuse_pte() will wrongly install a general sense of "future accesses are invalid" swap entry for hwpoisoned swap cache page due to unaware of such type of page. The user will receive SIGBUS signal without expected BUS_MCEERR_AR payload. Fixes: 6b970599e807 ("mm: hwpoison: support recovery from ksm_might_need_to_copy()") Signed-off-by: Miaohe Lin --- mm/swapfile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 346e22b8ae97..02f6808e65bf 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1767,7 +1767,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t swp_entry; dec_mm_counter(vma->vm_mm, MM_SWAPENTS); - if (hwposioned) { + /* Hwpoisoned swapcache page is also !PageUptodate. */ + if (hwposioned || PageHWPoison(page)) { swp_entry = make_hwpoison_entry(swapcache); page = swapcache; } else { From patchwork Sat Jul 15 03:17:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314366 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 CF83AC001E0 for ; Sat, 15 Jul 2023 03:17:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 925D58D0001; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D4066B0078; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C28C8D0001; Fri, 14 Jul 2023 23:17:27 -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 6BADA6B0075 for ; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 40AA3C0223 for ; Sat, 15 Jul 2023 03:17:27 +0000 (UTC) X-FDA: 81012385734.19.FBFC778 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 8A92A1C000D for ; Sat, 15 Jul 2023 03:17:24 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=1689391045; 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=m0sydhJCuR1Xxpd1jnmiNRMyod07FiDhIP+UyRnnN9I=; b=KaWPXJSKxgkG2DZ6vLTXb208u+KzaGeC7rbxJJLB82D8ie6l0YvegDWtLMNF0hR1uBxpcU fqCM3e+CG6Vxi38y8qBKcCVguDu7GEch4Mb843F2fctj/PRwPYNAU0o9i91ZjaP/BqWIZH V2xGNP5wzFF2PNv602mbJOBJfBT108Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689391045; a=rsa-sha256; cv=none; b=Fnpu3frmLvOFb1E4s29gxbSbEdMBKRQjk6JVAGmMbjt1ZON8KaJNi8o0P4dGleD74nXRV3 UQ7Yx6C3Awu+pV+4QL4u2c48wue+CY+bkneBEGrBI/9bpy4gcCVtRFEAb5PEfIKDY9N0WB jCeE4LmwaPkanL9Zf5UgTgKcxzzxBSk= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2tjk2f2VztRB3; Sat, 15 Jul 2023 11:14:18 +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, 15 Jul 2023 11:17:20 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 2/4] mm: memory-failure: fix potential unexpected return value from unpoison_memory() Date: Sat, 15 Jul 2023 11:17:27 +0800 Message-ID: <20230715031729.2420338-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-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: 8A92A1C000D X-Rspam-User: X-Stat-Signature: xrt17iuq9qxjzo77wo1b4zk4j8rp1fup X-Rspamd-Server: rspam03 X-HE-Tag: 1689391044-840775 X-HE-Meta: U2FsdGVkX1/8Lbeh3WzC75/V9Ua/wIDOIrr9TfSuJsi2lNKEjmzVYy00WYrWfQ6ayZvu5D1YgV6RDTcyG/rDbqpUXRrCosecpWr9e3RbnaBHS80LSgnizA/N3NsG3P5dx+lRAHOmd2sQCuTDrZYtQq42T9ORbAOJMtrbSN12WVd93UbIphib5V5S9qeJ3Li5j2rW2Ug/1NBcbM6kt4Ehunx3RpL6gJdRniZkD4iA8TYE8z8WSZB3Zkx1PCxXZgV4+Lj+d5Zz8I4/XtFYrbpFtqoqI/BKOwTy0gYJBEwup2RvLd0WMnfpwdZ0hTweSSgVJNW4PatrFbILWGkD2cxTytjBe52c8iqSl7ei8b9TN738cQI4XFRvMnYOZje7JYBLW461t8F0fL0SI6S0L9SXMhXxpH+CSLfMxKyW1R5+1tFtAb62/MCHatYrs33lVaCr9Tpko3KHyK5S3uWdQhGXSQyu5kVkWbKHP/JQ5HO+Go8kc0QMuAWiDZw3cF9FoLO7WA9ZdKBxe28U35aw9FraxSMYpyIlllgyypgTuG0HGdhgNfMC8xVliP+m+FSgrJw+DpiZM+HWniYD5TNAJ7ZK3mG/QaPCnEGCZ2Xh8Ivx1deKSQFQZggRjBak5eBqtuSFS9LRFrFjEhdl4Np5g4JGd78wqMGCfqabe8yiPBHdJoa4XsuFeS4kDhuPutEaSx5UqjmaGCAJ3g6xUFpTVge6dBledp2xAYlH0Gt9etKDdx6jkL2oxp7+TTziYHYLVFRhFCo8ncGgPu3zBPjdmPUDqA8wlKV13a0Ye5Yx5U3uvUNPWdqX4S3e8xAZ7Axshtd9kf2oURwQheh/0WYJ0KNwreN8f0g9NditjGUQCmAD0RCY0cUnZR77KPTfrNbUBvnCS3uhb6UP3x3AM3qqrsT8a72JA6Cw58R0qn2DOTZyqGQZ/oZkSi7ZVeig56u97r+ifE+iy64H4GJSs7GcyA9 Sjy7Lz5D Jl0GkUeg8puYVGwnglPdLGQQJ8gltyf0qlsJwghvVqtCmldJDs3DlJt3CbHxPcEVbjLK/06wuN1dRnb+tCtNHg7+WLuC+1UBnTaYhrVWOijaeMNRWc4T58HGRYAxQiRskauYmyfJYUI/wv+ZLT0NxzP0usJq9rEkiwlELXrTKHvsfdsRKF2WVKLVH2J5QlFzCtsie 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 unpoison_memory() fails to clear page hwpoisoned flag, return value ret is expected to be -EBUSY. But when get_hwpoison_page() returns 1 and fails to clear page hwpoisoned flag due to races, return value will be unexpected 1 leading to users being confused. Fixes: bf181c582588 ("mm/hwpoison: fix unpoison_memory()") Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9ab97016877e..ac074f82f5b3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2546,11 +2546,11 @@ int unpoison_memory(unsigned long pfn) unpoison_pr_info("Unpoison: failed to grab page %#lx\n", pfn, &unpoison_rs); } else { + ret = -EBUSY; if (PageHuge(p)) { huge = true; count = folio_free_raw_hwp(folio, false); if (count == 0) { - ret = -EBUSY; folio_put(folio); goto unlock_mutex; } From patchwork Sat Jul 15 03:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314369 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 4D318C001DC for ; Sat, 15 Jul 2023 03:17:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C8A76B0075; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52C068D0003; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419D56B007B; Fri, 14 Jul 2023 23:17:31 -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 2D8786B0075 for ; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 08E5D16037D for ; Sat, 15 Jul 2023 03:17:31 +0000 (UTC) X-FDA: 81012385902.22.9AD9C33 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id C8E3F40002 for ; Sat, 15 Jul 2023 03:17:28 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.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=1689391049; 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=de3/uVI4BBSVuMe4i98/EN3DRFaqVu/lA8S64yZitTk=; b=c4zd9NDVS/wKAkA6jEfJ7mmMzB9VujYbbyqKr7t7ADWcJWNxLG1mZKMRSZvB2ZaOIJVchs wpcclQSHVz3aK4Q2MZsmwF4rg9rUlp35H5LEJf6Hprl86I7xJS43PEXcFmFfydnWVlLJeF yqGkkfrUexq3wPtkaSBQrlTthDZzEJ8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.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=1689391049; a=rsa-sha256; cv=none; b=LEhPFHJqKWPRovk+2u4kgdB32igjunMAqCqIoiJjCnZn4q8UbQMK+f1Lg5ijj0ypTMJGmV hzgGN0rjQ4kb7wmUd8zEr6YpamtP8kRxQ2LrPxx5qOC8QUVkinNtQ0BIBIQAi4aFZBxG88 QF83J9v2Vh3v8XasK3JL4f4rLc92vQg= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2tll6TXPzVjRT; Sat, 15 Jul 2023 11:16:03 +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, 15 Jul 2023 11:17:20 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 3/4] mm: memory-failure: avoid false hwpoison page mapped error info Date: Sat, 15 Jul 2023 11:17:28 +0800 Message-ID: <20230715031729.2420338-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-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: ba6rn7aqpi8dnqdtm4qkk7gbrwtiqeb3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C8E3F40002 X-HE-Tag: 1689391048-483991 X-HE-Meta: U2FsdGVkX18F198116rFZ2MMMlywIRxtaAiZUpU1/ZYvuz49cB9ap/X7yfoRNadKr+wgQtzKzjg+1jo/eIkWUTOD2kJt0VyksFmPcayxZQaKULUBQhzEs7xdYyqHCf1rbEqPRH++f7WmxP95NxgQa1BYJm5Lt3CfGY4BGzaoG7s5Dbs/bh0KEsymobYjfDuZ1IBiCHjO6GOgPfbEzC74HuZeZlV0DrxjPUsekfvjZWKbc1ij7n+AfrbGmSOz8m0inJoDxrTOXHVNyPEKNt+oKkRrx7nZEEA0rxwx4KRKnubxWyDlz+LDGUXbTe3zzBmtfUPm3XliH7HFO0rHdzg12XDcX265Bt5hycoXcIl1cxeNskwTL+8dk1AGRtmSyqgyb9a9lyMjp8sdUw5tJAXTZ5Au3ilSYo1+rif9UrGYzNoppH11gA+gSKVApefHSFbMNGBSGBgLZVDt1QBC8kSIro7qX2ut41gblQ4cdQ9ySWuon1h/gV3vENtSskWVtmdyviRCIdI6ncFSxoqQsQU7u07ymOE4nGDHAyxZLVa/2mz8Ljk0PI4bPCi7m7DPgRLSpKLBP1XuuMdD30GgRP8OYJl0waCAkJnKRRsE+3rgDlqLtUmInw2wnOkcPQksZinYwJS/e50KBkahmoNRK0ZXA+/TLBAk2dhApz7qA+8cFG7lGi7exoT/qXRRtJlnCwxQ9BQL8m19px9jLhgrWf5cdHjnXkb1Altl7/JyK06iGeFJZtdS7yYO2UneaEAwwW5FdnAIn/CTW75IlFRf7Zw5rVyMYzL82lgmcWm3Vc/pqp48qmjIcg1vVrn54ET8HooIqQN551mOcwmFuv7M86ENZKXwfX+iiEhnnnzPDFqawq1hOgtwnos3QYzmplM/DP4MCnNSkIvwWO8sy+CbKswscr5pBFwESz9rWBt432POXLI6P94kb6f7eNRWemAYYW2smsHHQVC0DA1cbk5LboW aCr104HN RH5qm2UkAZlxEbOm5mvbxwgOZ+1xr1Ffcguue1dvHQbw936vtaGNIf38/mX+h3v9HfW+FHVgjTH2nY6zjMaxZFFqc1cCuHSJNC8a97eo3b5xlSuFMl/6jyDne4zGU4Yr6YH2hwnFBEVGuPuY= 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: folio->_mapcount is overloaded in SLAB, so folio_mapped() has to be done after folio_test_slab() is checked. Otherwise slab folio might be treated as a mapped folio leading to false 'Someone maps the hwpoison page' error info. Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin Reviewed-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ac074f82f5b3..42e63b0ab5f7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2513,6 +2513,13 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } + if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) + goto unlock_mutex; + + /* + * Note that folio->_mapcount is overloaded in SLAB, so the simple test + * in folio_mapped() has to be done after folio_test_slab() is checked. + */ if (folio_mapped(folio)) { unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n", pfn, &unpoison_rs); @@ -2525,9 +2532,6 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) - goto unlock_mutex; - ret = get_hwpoison_page(p, MF_UNPOISON); if (!ret) { if (PageHuge(p)) { From patchwork Sat Jul 15 03:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314368 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 6766BEB64DC for ; Sat, 15 Jul 2023 03:17:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF5758D0002; Fri, 14 Jul 2023 23:17:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA6CA6B0078; Fri, 14 Jul 2023 23:17:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A34CF8D0002; Fri, 14 Jul 2023 23:17:28 -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 8A7366B0075 for ; Fri, 14 Jul 2023 23:17:28 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5BF46160435 for ; Sat, 15 Jul 2023 03:17:28 +0000 (UTC) X-FDA: 81012385776.09.F7592CA Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 0D8A4C0013 for ; Sat, 15 Jul 2023 03:17:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.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=1689391046; a=rsa-sha256; cv=none; b=HarPJnLIxcpuN0nX3YYgA4O5kwycznS4AgzMOBfwyCE00Lh4PAF8UHgw43Zjt3yacTncqJ soIKQlfimCujo4t5bEyFP9uPKBUbT9ZP4M5BH3jS86KWtg/msalxmTJU7cyV3tcE5D68W0 BLUOuFFKhrS3+wsBqcXL009UbGNreTM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.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=1689391046; 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=6SR4RM1lW66uhlnv83Prq7cpa/zrVS70ssAIFcoXwIs=; b=EdyDo/kiobt1VwNMEdPvsu1mHVytpLPouIwf7/xVkWr9lil9Kbos/0Cp5YKRV1v7XQXCOp SHVwjWmXeCT/WB5d6wmVwbftZI0qKjpvObG08pHJxtIsEru4RlVVaQrcW0Nr1a+txRM/+X fFALsRtYdwtOi/nMyQuErAzHHm2Eix0= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2tjl2GlmztRMF; Sat, 15 Jul 2023 11:14:19 +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, 15 Jul 2023 11:17:21 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 4/4] mm: memory-failure: add PageOffline() check Date: Sat, 15 Jul 2023 11:17:29 +0800 Message-ID: <20230715031729.2420338-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-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: 0D8A4C0013 X-Stat-Signature: gpjd8uzris37uw1z4q5k11qwzobw6ei9 X-Rspam-User: X-HE-Tag: 1689391045-973979 X-HE-Meta: U2FsdGVkX18Gm+ZJzMMaZLfZEKilfQQBwlnVjPrFa3g5tbipJ6+u/mYxgp4j6XZI9jUY6Q30TEdRGTkjjwsezkbyastP5aXtJQWVltF4Q0Ie/Jd8XlDxBz3qMzgdaDnp7JIMRZlWjyGarJ8k8UZDUrWUW3Bx3lMI6KexHVjl+Ek/htdpmCscC0LrB9PWIyIlJkv2eqKBShWDb2twZ9ySI7QfEMQecBkhYSPMX2pu+ApdCuAtVNSalNZELBwGpUIiRHfM9ELOUvRAqkbGAL/LNBOQslFm0/7Q0IlVGkJ5eyI5kmgIE4wqfzlAxcYydyrCs9sqVPn/gseEc7nuXzgQHipI4W33ujN6nBzcmJswMEZneLYJmaByGC6Q9VI75Nid3CxE3YF5dI0qfyMTrgdfgIMMCp/YB+ncJjeNSorX3oDMZ7/mestzCc2xUAS97eg3d5WjrHJtaGam/Sy1xH8+Ft057/CY3KRxysEnCFAowr72yvOQttUD/bLYkL/RGqSLKmqQS9JWhjzXVs9wjmo5q59q5g6Xie8cnx/A31VDCJ82BFOkH1bReeJhZ/CnHU2eA8faGrO7DJnUcicLlOazQDqRXwXtMCmcoeEV8j54FtRdqKgrNHYdkC09rZyq5ClAGv8DN/zegqhnIqF+ZhdlitDUN/0RXwJEzuVYw4vm5DGRYlmynN/ifwPhm9uKwqT9LzzSqFjTOzddHZS5PYoZ2/VGfteMeulP6iTVZ4wD7xddWlLc9IfBfAQKECqb1JM9IC9yjW5z/eTjmvgqx1AHBcuDfhUr+n/bzvi5be4WNQWP9abxGrSy/t5IIxo8qOoCTdePotIK8JDiKgl4veDwWT2fvRuiFvIAzub2a2uiZAEKZjXyFay9+u5C/enS9y5O6TaNGKRh6dN3HEmJnqbSIb9+yCHfrROgIGOaDFI5g9eyWgslr9Kox2EFyb2DFx4szRKsnSvrs6kmeWC1p7F no0N+ibV v9bVFAK9QXVyISx4kdjWgRH10riQBg92TESWoP1pgHVK5IEOLj5T6TNLwWSAC1fWp3kSZMlU6wpAdnG+8hHbpz7Vea5FSmGr0+R0ki23RatVd234cUluOq5ES/BDF/ToLfda+JmHC1BG4rpM= 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: Memory failure is not interested in logically offlined page. Skip this type of pages. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 42e63b0ab5f7..ed79b69837de 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1559,7 +1559,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * Here we are interested only in user-mapped pages, so skip any * other types of pages. */ - if (PageReserved(p) || PageSlab(p) || PageTable(p)) + if (PageReserved(p) || PageSlab(p) || PageTable(p) || PageOffline(p)) return true; if (!(PageLRU(hpage) || PageHuge(p))) return true; @@ -2513,7 +2513,8 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) + if (folio_test_slab(folio) || PageTable(&folio->page) || + folio_test_reserved(folio) || PageOffline(&folio->page)) goto unlock_mutex; /*