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: 117419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3806998vqx; Sat, 8 Jul 2023 02:25:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrN8W9W46p4VF3N6K0L2y38E5qzf7eur+IbrDKH96E2j02bWdd3cYzFfn8YxpVwyy4XUcT X-Received: by 2002:a05:6a20:8402:b0:12b:40d3:aeb1 with SMTP id c2-20020a056a20840200b0012b40d3aeb1mr11736219pzd.25.1688808345960; Sat, 08 Jul 2023 02:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688808345; cv=none; d=google.com; s=arc-20160816; b=mHDP/1UiEML/7ZbnD8y4h8DaM9xn4T6Mn5Kz7uhtqH+Xp/OW+I/EViMUvAcR0Ezpud fQ0fSr9n8MjzTfAwyntcoSUpF/R93YgOaK/LZtVfUIS+BVYn9sAPfMzEkpD9H9D501aA ieXIok70uRl6mkKsd+kfMzptv3JEUaYHoMFe1eNN0nruYu7whJy7PD7oyY4Y73oKhAJm NmS3iL46Y8mZ7tVq/f5sv4KRhxlPZYdf5KTJoiG8PjeIzEQRn+4+/xK7oGOxwOCO1CHS 8sor5TKJnI1Hlj6gGwYLNc4W7DpQF96RD4xy1kgiVP+Wj1Rg64JLjVLhKaTvGKU2RiDk GrPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nu0T+4OifjpWSZTiUfF2QlfBWJeikYeHAbyQgFEM6So=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=N7uxN/I5m2EaoZtn7pYj577Y4O6w3lzBmXqYHUPyHdhsZ9eTva3RDSPhE/WmnbcA29 auAqNDjMXYJRKrc7gw0omk2W1YnBpKFCyauMGJnH8eszAXUatMy/KzfvQ7znmgdHSKmX nYPuqDCc1NHwVzXXhoQXNrhNjkkYfWg60rdlziW2K7DJberJyVdQuBDS5Jqtt446nM7/ GN8CibU4zbl25bhKD3l+mPFXSrhamha6zqVFgB7qOLSx2AiLwgJ2lowwaDr6GdrUTDyw WXhi3sV3wbVzrwyPhMmfPK6SmvC5zWc3W1yGrmuH8EIINphmGYeokKR6Xu01mFUEYaBS KrYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n125-20020a632783000000b0055757030059si576365pgn.3.2023.07.08.02.25.32; Sat, 08 Jul 2023 02:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbjGHI5f (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjGHI5d (ORCPT ); Sat, 8 Jul 2023 04:57:33 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1A51FEE for ; Sat, 8 Jul 2023 01:57:31 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770843899880177360?= X-GMAIL-MSGID: =?utf-8?q?1770843899880177360?= 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: 117415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3802275vqx; Sat, 8 Jul 2023 02:13:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOAb3Sshp2h+MQXE9LAaCnFIUdUQ6blmnytTzMpDe2vDPWVePkRtTMkoJ/cEpKxXdgOBeD X-Received: by 2002:a05:6870:eaa3:b0:1b0:5eeb:319d with SMTP id s35-20020a056870eaa300b001b05eeb319dmr10832076oap.43.1688807619412; Sat, 08 Jul 2023 02:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688807619; cv=none; d=google.com; s=arc-20160816; b=Ae23Is6acLtSjlnL6o8O7A6lUQ5aOtftWbiFuA+MsZUFBN/VeiOihFYsBXYZgqp0cp A/EHI7sfaaVkoDx1Jn2Wr6kXs60YzZTxYuaIvl7LGFnKOccCtQ2rqLsjNWs8no+GoOh1 QkZhQ/IVYAjCfXVAz6X1zJwOfmV6LeqjOpRipLr3INtKGAwYl7MlCo1MoEO+nLP+ulpN n4TAUFLINl6KEJf6PHvfGHHL5wtt+LqTSH7/uLnQNZLdwr/IIrX6dkzstVxWA3WaGLXN 1y30TE/JxFJE8SNbrK0JKcvssrKw8dFkcciKPOfq6RVVn3KhsAz1alEKFAhEIiFGdPb/ Apqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=t3jGnFlBe2e1gDFOxNrK0L2EElNUaiKTTYXS7V29tIw=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=0lSp6CWXB23BbmxA68UQC9MfGmb3HET1qx1Y5PCTQcUkN9/cKBWC0wKRwRlLuQ2Srz zzPOjC0EHr5SvX0FwABn7eXIPy0bsxoXzINDOfLkSciIakH4+fsNoVwHowWAqZ21BUmx l/7ItDHRzM3d7CMc39hcFq+ovqa1qK4RVXNHRqPvfXFfS79W45CUW/IvIPutxaNI1yUW ZW1bogNkKCzBDYOkI2Livz+fs+M4fcw1C6J/mAFi4rzMJXKDBVjfOH8dkkSx13cnLV0H aoR9IcFUU9bfv9Bj7qqFzc1uXiovuGKCnkq31d46YNwUOS6jJi3kXi9sDJazu11UoVLU 7lnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a17090a9b0400b00262d692db39si3914468pjp.12.2023.07.08.02.13.22; Sat, 08 Jul 2023 02:13:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230328AbjGHI5n (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02EBE1FEE for ; Sat, 8 Jul 2023 01:57:33 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770843138304563654?= X-GMAIL-MSGID: =?utf-8?q?1770843138304563654?= 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: 117414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3795811vqx; Sat, 8 Jul 2023 02:00:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFNadOeiGnWUjZrTQHthQZecLT0gUvK8XGXSCwR7D8w6pkGhD/4EXTpMAOd7/XKgQJHSdLg X-Received: by 2002:a17:907:6285:b0:978:2b56:d76e with SMTP id nd5-20020a170907628500b009782b56d76emr9789047ejc.12.1688806818399; Sat, 08 Jul 2023 02:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688806818; cv=none; d=google.com; s=arc-20160816; b=rB7Bv8gGDa3xa1W0wMMo86t/nB59rSP2UJavdYrBqnP44ReHanQezn7E4hTvgig7xJ WT3ZdZVQp6X6g5ESU5BvHi1jut+klEgAwqVw6dXFGS97Qi2AC/opRWNkfb+K8CgnSy9D RvEGsRtJkW+RU3q2tT7SGaIp5RbFzWtcA3CjJcu552BKNVyEoM9NWLLS/EAGDvaN+CtM 0Xu/bYZJy2OllN3PupbyDmq1O8p31s7orwZlxAuHaQuRJQ6mHkra97NJX6jvl5QbY8ZC bm4hCYuNr6mRptqFL+N7nKuVv8DAvymgx+s0sQaF3V6NEW7PbX5oRNhtlA8gALipQVES b7cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xHd3BS8xVECX7E/sxvVqFWVpfjPb2IafD1iyx6RNnLk=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=EQp3mVkqLrMOoJax+voagNJqfP4ew5tyH97J+uPwvYkGShmGGVOCfPU8LE9JE1S3p3 w6yhVAwmBRolyosmMHkXHfhwV/XYbBLc1kbS0tC/eqUrQsvdrzNpKS+UYGqYbmAof14D 0BdlWbmVb1pSQeUsSxxrpW+RjFi5kOJQq9JO5rOkfLJp/Jw5gky9+JxlS9vj3ZDNAqPO nXKd3tuvOI6itpPTTYcRkppJXTdua0QShgS/M/C8SI8os49C2vcKW04QE0x9V0al5HWn 0+au6rRqb8IVcDqKKoMjl8vF28UAXF94CsOkKLx+8wdxuHmKpp6LNJfK3Qf6Z3U2Fuzq AjVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw13-20020a170906fcad00b009829ea99a16si3025909ejb.577.2023.07.08.01.59.54; Sat, 08 Jul 2023 02:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbjGHI5l (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D8A31FF0 for ; Sat, 8 Jul 2023 01:57:33 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770842298482669126?= X-GMAIL-MSGID: =?utf-8?q?1770842298482669126?= 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: 117413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3795691vqx; Sat, 8 Jul 2023 02:00:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcJ40kOLyC3EupT4Y0ErMPI5xEvlkyyVKBSO/IqFhf4hxhfFTgqdoiblSUuQQvU4g+AZQh X-Received: by 2002:a17:906:5946:b0:982:bbc7:15c0 with SMTP id g6-20020a170906594600b00982bbc715c0mr5590903ejr.66.1688806804874; Sat, 08 Jul 2023 02:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688806804; cv=none; d=google.com; s=arc-20160816; b=sQ1wWY61n4F7/yaeA9qHE49nyh97I26FQrqqvOiPyxx5L/Iqg2So7Oc2CIMegiYTAP B+eKD1Oly3zpCi82m/qyLQRDvuFcQJwHPevfTaYBOhHZQ/6mys6iBruFslz3JCATu8KC eiYIfTA8Xw4UlDiYwAa/blf8S1GXj2V5BDEshZhzn1WnIyHzn6hJZTpvEgZjMV/GhgYx pRaSjMuDXXGQ5VpdCQrFK05Jf0xCwu0ynyV4tWt58rCEg6qnKp1AmdqTGitj0KwQTqcE ZnSgRXG4Psc/80KExZfibKsClRYFXaXvNBXwB4ih5syyJJZKjMjmjS9Jac16CLobBAre 4A0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LCrOy4OLsHpFK0OuO84MTfILpCt87VTlpXIdT2mKjQg=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=ZYZ8d4fOt0HRsf3TrYLsob2CWfaW+7Cw8zrXud2khp220mK0stNePC8XUhz97ULO3U MHwqCfmwd4+pSWaRDqMnDZC4oTPZe0Qin7gfnDpAxTKbjizw+m7B0s8JST0wZX0Zmc9d ywnQWZ+iod7nCpR3t9Hrheh6HVRDICBQZWYI0MmYbKVhHw6WPILDatjgpMRnTeojx47w MN8M78YrRVFd/A2OnRVfMm+iYfattixNkb0ag83pZVKVTbSP/aaO7HGwAeecDuo0Q0hd 7nOsTj7gshd3x5rawTNQTRxwVKlhjUw9zeuIpWmGp3dl8cly6/LQyiWvAfiOVOvBC5Mm 18dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br17-20020a170906d15100b009932528281asi3197446ejb.579.2023.07.08.01.59.41; Sat, 08 Jul 2023 02:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbjGHI5i (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881281FF6 for ; Sat, 8 Jul 2023 01:57:33 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770842284202805780?= X-GMAIL-MSGID: =?utf-8?q?1770842284202805780?= 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: 117422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3807370vqx; Sat, 8 Jul 2023 02:26:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlHIVQoCJ1vO34hQDLbblh3Gc9dU7JIFk3NCBWQEYAYqTtW/3KL9tNEiUbC8XEGlGk5R5hqx X-Received: by 2002:a17:902:bb89:b0:1a9:b8c3:c2c2 with SMTP id m9-20020a170902bb8900b001a9b8c3c2c2mr7680066pls.37.1688808404922; Sat, 08 Jul 2023 02:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688808404; cv=none; d=google.com; s=arc-20160816; b=i1bCAQXnW/LwkXpozslk8oSpW8QAfy0BJ6vn1upDeSHo2O2iMjvlTZQMRDs/otPM75 bxaOd07vhfQ2xtmImK8V6jzkv4R7P2dbQX80cjogKDALiuMUJy0aWxwTN1gHgdQx6Ysg W3qGnUITcqa4CVfZnh2KJrJ+iDEg6EzZtp0PeBSN8O5rfBlM3bohxwAUJ7ggpeCZS4QV 9uwoz06JMsCscdlXjV8Ndg8Xk+79UG9rdTZwY6FL4JU/UNyu297HEfc6rdatAg1U6tDA kkWT8RCiVz05LXP2Ceyp9T/BLeNO5+tJMuOwT1f8CaKoCkoGwn70LC4vuMGriuOKl0EM IJOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sRPaYEQzZ3wDrly8cKtU5F8HxsL6XapCq9OMk94CHUQ=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=Avn5H2IKEEBSRa6L1A+IRfwPANiSM8+lB6QpbQQ4mQaiK8xFomHbAUZi2NXxDg3siR f3ZzCdl//Vpim2Nrf9MN4DxCz5Z+ovEmpM2cZX5+jVTBhQK2xFTJjRH9SGDZqnQimEzx 3fcNkVWqUTNcbHYAlvo2Okp6rO+5861DRj3N4tqA9T7kEaZQkQiMSwaQHAbzMQAx7mA7 HSzGS7HCxn5Q6dqkhIRCky+RGwDkGb6vERgCs9kmyT3hSTU5D83ow+wVRI5Ri7mZjXuO 6nEuO0MsgzE/rVxN1ltyhxVqxscYSBXwJsHa5lKnhRmpwIkyMehSqx3Zgc127FZ1HEnt mPJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r17-20020a170902c61100b001b89f814e78si4927840plr.559.2023.07.08.02.26.32; Sat, 08 Jul 2023 02:26:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbjGHI5t (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312E72107 for ; Sat, 8 Jul 2023 01:57:34 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770843961755526893?= X-GMAIL-MSGID: =?utf-8?q?1770843961755526893?= 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: 117423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3807796vqx; Sat, 8 Jul 2023 02:27:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlGruGlIzQb3VrNGsJnY1qqBAXjxa6so8ztodDVyh010+7maN4EeKxscsqKsPc9YukwnSJiG X-Received: by 2002:a05:6870:73cd:b0:1a3:5de8:e78b with SMTP id a13-20020a05687073cd00b001a35de8e78bmr10093401oan.21.1688808462525; Sat, 08 Jul 2023 02:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688808462; cv=none; d=google.com; s=arc-20160816; b=BGgxx1ZZazIuu1mUZ9UJsFH8hR6dqX5pRU4O0bIaqgcsXC22USkGvIoUqrff/cN3zI HpE7HY9dKMOm1tXcnXVV3GE/ZAdr0ZEGCOkmwRpRnU+Ygrfz48CvtN41KwBgjo0lXBIq irkkCqKc1x8OIREZRqT2MF9sd/XiBLLz5bRZu8a0iH8vULElAo9VCD0ICJ4wvVBRdqE7 86m91LQSQUK/nVnOlckl5hCyTc47/dwRrkWCiQmqjz1WucIW7Gi1rwm48u+AU/MRU0/g Wwrk2Jsxlpw5imgiVYTDe1eMp8Nu5s9Z/AE12Kypgqw/NdZOeJcx5QaoxF0Ucw/X95mt LyGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SdGpbb556DGksW+H1uvavfz+poJOo1vWJOFJPx6ylv4=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=QU/8jsmGLUY+dUZWow61PqWg/fYLBidtnHtxryD6OUy1PEfhEZsArvlQOfohwCedxw VcnD7JDV7mbsrN7p8MYLyEo2kFizqorbUpOXm5bAIdSQuuPCWWGTOqiJkY+gBAfPVV0B FTTVEr+u/WZYHfLjh/dE5Qvz6tVZ0OYddXd6fzqo2VJDGq8kY8tO/ejFe6aowrhw7mo/ Jkli5BUc3Uhuv8MON5CdTB+tzV5DlMn/e+h0CyL2GP662jFS+TzvG2oaXhQQcD53SSJG /V6RyqUuvgG9M9nSW3crPZURufzwX0WfASK9w8NE0AeOFbFtUGHAhNaZEu1/D6ho2/lY 5reA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x64-20020a638643000000b0055acc7f8085si6055693pgd.367.2023.07.08.02.27.29; Sat, 08 Jul 2023 02:27:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjGHI5z (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjGHI5g (ORCPT ); Sat, 8 Jul 2023 04:57:36 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58D781FF6 for ; Sat, 8 Jul 2023 01:57:35 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770844022568405296?= X-GMAIL-MSGID: =?utf-8?q?1770844022568405296?= 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: 117421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3807230vqx; Sat, 8 Jul 2023 02:26:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlE40mcTEYkKGmpeQ66sbrUkKBOJji7cqFTQcswdStXYy55bihUh2xfNaXWAm3AgsaoSAmGz X-Received: by 2002:a92:c68b:0:b0:345:d741:33d with SMTP id o11-20020a92c68b000000b00345d741033dmr7417210ilg.20.1688808384593; Sat, 08 Jul 2023 02:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688808384; cv=none; d=google.com; s=arc-20160816; b=o9FmM07dAIWdsWo+86t4wOvWouYJv2pOBsYbi5vu5JSbP1Gv+unht7m1M3aJxUobN8 3opaBeNMjdg4wxiGRldOI2xKpw5T76ltEDEw46tPfENnZ9cu2VDP/Y769QNfBbXd+2hI DahTsEQdG6zyLRtClwqosr5CJwbu2URbJ7DfvUcZ2NZ1TyS3x2qH/atzAIahcGVDqnxq zeGREyGCXSyNMog6TmT1MzzhfvvSTFExiW9jWaNiRX0tTwND32Dni5msDIENp2QIVoAc UWKFYHsEUFsKcif7hMzIhzDfVLfcPHSBfEFoslmeaP023pMIoVPrhABhd2ijO2dobUHG 5yfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4zvreph+WtV4FNPz7Sph1CKBbIMj5dh6CNbYbbIKYXM=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=pq2mFokjpa4GbEua/fpNjT43GB+lgLCkHvkkRKVKHA4vb8oV57sx1j8ZGjejTXikJW dggJk5RmmBTE78C7DCHsDNTdteC8QsyAo2j3aCuGUsMa6AXK0POi39dRPzpbWhZOielX KSFFxCwaAyg4J6ODDbsQ6WgwA8go+PU/DLmIj+vEAzXT2stfxI6qAjhSq1xwyl+nGbc3 tXMSEE1GPgnX3aX8nJB+CFH3EynPDoegas8/UthEIKJ1PCF0kgZXdIM3Rq+/QYZ+QBbi iwQ3DijEkjvwL/yCqh+4Wl29atHP+yN2vxvlEtbUnR/5LH5huecC/jyvo4NPcSD8nEET M1nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r17-20020a170902c61100b001b89f814e78si4927840plr.559.2023.07.08.02.26.11; Sat, 08 Jul 2023 02:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231316AbjGHI5w (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjGHI5g (ORCPT ); Sat, 8 Jul 2023 04:57:36 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1968A2114 for ; Sat, 8 Jul 2023 01:57:35 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770843940848204430?= X-GMAIL-MSGID: =?utf-8?q?1770843940848204430?= 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: 117424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3828979vqx; Sat, 8 Jul 2023 03:16:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlF7rQ+EFiid5WFTy2eZHR6XUq0wEI7L6lYZ4H4JhiAe2lEcHM9V/ZoFj+pIPMDSwSj20flZ X-Received: by 2002:a50:e606:0:b0:51e:d96:15e4 with SMTP id y6-20020a50e606000000b0051e0d9615e4mr6042913edm.19.1688811378249; Sat, 08 Jul 2023 03:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688811378; cv=none; d=google.com; s=arc-20160816; b=JypQ6Stad4o/wDWzv7lwxLiYRXACx8d30JKU1Q5o4rjW8AVof4+8uDzVUnr8syWmwx znDIcsUQbr9ZUFsx3KGtX32n6u2P9iozbdu3iBGXQbIK+LsHDaKyaQQb5ApY8yS3hMME ulcOtW6BdTNJkQrsllMA8EJfCP2hk7EENt3kj1DK3ke8sqar3fgxlpPdOv4knF+JuogU +O2xF+S3iYk3A24rcVgp8TOZpbtVG4MtSFaYGOqshugxo09nW+yPJFG/q7qbEq/yv/fv uqxrOwtuAIIXdUeESU9Fk1QV1E1+1zgxAK4Ym8lOl/5N/uuYei41jWoWwEfEmbQG8ZHY Mehw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Qv7v0MakVggbJJx0U+5+eQj6+hfyeFZeeQvIWRA1lsE=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=FfpzLWFgIqiLgQIFDnBfvQ8js7/nXVj4NyouH6PIQ2bDGkHz4JpH0BdkUNIAvpxrwI OWn/sjVtwHOl0IZx0HEkOZw64yB8a6FOZCvoHghbfHaD0iISh5uiZoVzZRI/IzAHdjBG 0hJ9x/zvMNLu9+nbzB3TAq9xjuqJF4ra6y/pzm2EeMUrNY21N28HjMeYRf2rfD83mt8R qG49YWVCzQSmE/WYhX5RRDx4Fy51osiv1UNSzQqAF9A0GIYEKey3XBsNO+yOOhbNUbyQ b5j57UOw7OtoEn0+yuqLnQ9D02BxKL3f/TT+JUE2Mhc4CopY8/WOcCkW+cM8RKdkFEAh ImQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a50fb04000000b0051e26731172si3190490edq.672.2023.07.08.03.15.43; Sat, 08 Jul 2023 03:16:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbjGHI5h (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88F22105 for ; Sat, 8 Jul 2023 01:57:33 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770847079708933741?= X-GMAIL-MSGID: =?utf-8?q?1770847079708933741?= 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,