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: 118261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp265008vqm; Mon, 10 Jul 2023 22:55:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwGuAEw983fO9TnmxM3k1gkPt1WOsKAzxigNKsJURaix7+vohEBVtII0ezAK1eH6o/LIMe X-Received: by 2002:a05:6402:1a33:b0:51b:df14:594e with SMTP id be19-20020a0564021a3300b0051bdf14594emr14514234edb.39.1689054902947; Mon, 10 Jul 2023 22:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689054902; cv=none; d=google.com; s=arc-20160816; b=A4owMCk7c1XtQp4aK0Xcim4mY+xMk7tlSWyIGyRUh8f02M0MMcRutKslGuADq7GB03 QGzK/Vol3UBq1+vNsvTvKCL1cmTTNuPzGLjmR2ZyycRuyszWfDvdpsZrQeibjkodSnca v/oOqfO50puv4vxYW+MsQCmDiboZPuovpuy/YCpwqyXQrwXBGDtC8IAMrFOl3Iph1w6K TP9CHpGBCjJ6SFrPKW5CGdiDyO6L9D5c0gYRB4E11IszyyPS1LuDCuro9Y3LjRCvilcT 7Dy0s0FIfKz9thwHQpDnhaH8qI5/kApj6OR3XUd9QaFlauBe58qLW8vxffWpQWpEUWcd VTdg== 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=LAkEVE24Qv+BBjIU19L5nrF8dLgTZ+0ofSIBY6kqzZM=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=bpWtU3KCCuoUgIxfTuCzQEi4jw9MDqIEQygeVl5sVXsLKfUCFUeY/XgtSe4vSnWF58 Y1b8Htoc33BhXas/RjjZMSXJBt+tAQi19lmx+I1krSeaeo9GmVrvvkAgUenzMzMACPrg Iw3g+vOndaICgolUegsSqLsYRqzUTpIEA01HJzS/EOa80xQ/Iy+x1g8GOgw/tqmQgfxL BdjCvClmEw8gjyzZRlXBns8wB9ZGS64i1+nU50qdIXHbqexBafDdx5Hc70Je/gnkvI7j QtI0Db60u72K9APkv17Pe8RrOJIsYnpSz49URIYbJTrfJRDRZwhzMOELClt4P8PUEWWL 8drA== 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 d2-20020a50fb02000000b0051bfd21d20fsi1200188edq.87.2023.07.10.22.54.39; Mon, 10 Jul 2023 22:55:02 -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 S230358AbjGKFuV (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbjGKFuI (ORCPT ); Tue, 11 Jul 2023 01:50:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F61A1B2 for ; Mon, 10 Jul 2023 22:50:05 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771102434122595569 X-GMAIL-MSGID: 1771102434122595569 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: 118272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp269942vqm; Mon, 10 Jul 2023 23:06:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFh8Zo+B/bvlDYMQJWQu+A/fSaZbfN0STmdyAeue+Ia/TiuTt+b3+xpbOqiEkA26IVT0NY X-Received: by 2002:a17:906:cf83:b0:992:bc8:58d9 with SMTP id um3-20020a170906cf8300b009920bc858d9mr13502627ejb.70.1689055587079; Mon, 10 Jul 2023 23:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689055587; cv=none; d=google.com; s=arc-20160816; b=mErlP6bAicXhOzPDSHhEZ2RGDqjxTqkPwipqT9T8ozkoRYMA0dtFRZTUEUlT9WHrE2 8OTwZEfE5sfGs2tmFVh/4PEmE4nD4LsvB52FUfWQ2YWlJG4uBxx6csm9iI3V6nNHKNjE 7bHhepgmgdcg7Kp0qgyQIlqiWNB+8398Q1PYCKjr/Vu4MhPiF2YPWWnKoc1AsCAM+jti yBMkoUtptmnOg3Pej52o9frhB2vF7rnnp6tUZffnHwr838Y/uNktkgDroHeWXZV8ebun 9wELxX9aazy65HwIA/yRzXlO5xrV+UaHZ/DmEamqMr/jPM12HpQjVWGQQCY0OaTblgV8 wtQg== 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=c3+4PRVCOc8lFGp+68fWiH4guLJbERi3j/h49cE9di0=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=xX7KzsEdlc/lI2BLCJLgXgtTbes0zKX/QSkWqJ4CsK/D9pMzk2oA6+Ag5FvIOHdhsw DOysnOMHftGHh/6yJLdlJHD7dBT5PmLk2JpSSMZxBjVD9e0VeJoowJBHPKK7azKiUh+e uFWYgZS3SSVObieivydxKf0Ln6GYNZ5KZGmNjdjQ8HQtzq6O10O+0uHKYJyjXtU354cs 9tP27Tfx9oEHBmU38U9b0tvBftYQ1ILlc0oOrhwv1pAlqWrH20yuxOLEd5CTHKLr5/MJ fJBvQeoF1xVKVBvwDLnYuNWV9YHNcc0UQlVtH96qwbEpH8mo2PsEuXvP22fgaSiQT9sC Rf3g== 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 lc10-20020a170906f90a00b0094f34ed62d2si1233300ejb.366.2023.07.10.23.06.02; Mon, 10 Jul 2023 23:06:27 -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 S231195AbjGKFuf (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjGKFuJ (ORCPT ); Tue, 11 Jul 2023 01:50:09 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0A9E49 for ; Mon, 10 Jul 2023 22:50:07 -0700 (PDT) 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-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: INBOX X-GMAIL-THRID: 1771103151060676642 X-GMAIL-MSGID: 1771103151060676642 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: 118271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp267806vqm; Mon, 10 Jul 2023 23:02:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFxFOnRRmDK7n1mA5KzfwHamdBA1JK9USSaMxFNqzOz1x1HsHx8NWx8RCkcBAUL2SrlFMyF X-Received: by 2002:a05:6a20:483:b0:12e:6a31:37e1 with SMTP id 3-20020a056a20048300b0012e6a3137e1mr11577353pzc.61.1689055325403; Mon, 10 Jul 2023 23:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689055325; cv=none; d=google.com; s=arc-20160816; b=h9dCTP4VYQFehORIv5ZQ+x0pb21AlGnV1L4OpnMOrnJqT7EZU2/8wom0dlZVfK1LUK s/Hw7RsUYviYLxXrQPd8UxH67Vs388Q7TitXHyQPFUHRsc6keI29iEwLSJacEsTnFm44 mCIX132I605b8RYo3l4fAY/431Xp2emouRptnp7M0cP78TCp84hGrW/6o8GKaKdqDI2D 6cPJrCBrP6lr4ifZJLgKavJS3nJTBai3LTpDpYTkqtKh/u5lt4O3owD9Rt/FJPbSWDBp dwhSfA6xxr9NxBVzJt4uPGZl3Owb+z1p/oG9mqkOY98FyDz1MtY/w4qBPCkE5KtRvB46 v5jg== 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=rbVV6E6KX9xBwZyFWx2W1vSds59LeiPIy1pErc9efjo=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=FxmHHekNFGVIXQILesTgMAJZ49QY1hoxuXMtKNYbufM9d8TlETvQMikUC3TQVU0Q/3 3+X6uqnbMCLhkkdlTq6kSDRiDCvNSDGM7/k/pCAxXn0HwDl93jxiZaCjvetAcBnVxl1K 6/3Ktkm0A2pEWqwljK0MLYzfpyH+95QmggUEb1uHsEuALqeH6alMZMde7Spscw92GHrF aKPZ+PGzL+scrT6TxtEamL4Kb+KksUzbHm2z7ceNTzjwz+PIq0fX4WxufRHbk7Kzp/Qr W9nfeDIpIDMB8jg1IaGXl3iTwdgzyPtCqyro9qPqsAocIcz9zrA680dZ96zZKuBTMPRl qNmA== 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 im23-20020a170902bb1700b001ab29e00303si979565plb.426.2023.07.10.23.01.42; Mon, 10 Jul 2023 23:02:05 -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 S230128AbjGKFuK (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjGKFuH (ORCPT ); Tue, 11 Jul 2023 01:50:07 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1B71A4 for ; Mon, 10 Jul 2023 22:50:05 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771102877064561785 X-GMAIL-MSGID: 1771102877064561785 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: 118262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp265168vqm; Mon, 10 Jul 2023 22:55:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwMW7l8hw73vuo7PYC24KAMWT/QgR5DuyNoirAoqK69elgKhr3qXrXSSm8nQOZqvwLVV8N X-Received: by 2002:a2e:8455:0:b0:2b6:fca2:fc6e with SMTP id u21-20020a2e8455000000b002b6fca2fc6emr8982743ljh.42.1689054938590; Mon, 10 Jul 2023 22:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689054938; cv=none; d=google.com; s=arc-20160816; b=oGDX3ISOL3YSaV/PxvhEBhAPV5a5XPpS29a/rRNZncpBJvKLnov9jWlIwq6lHEXM9K TPtpjqANcIXHpuY1iQ6rsCzrI1NzqGKS1ALZj16UJie/WEEcnlqGqWPDqdlVw7WGfMap vSVad8x9fG/In0mG0ni8ru6dNFz5bBWuhFgGuIyD1xzeZq6+L3tpOG+CyotW2a1rmunI hTuM8AgdACfwpKg8uwwZt0Pgume54vtzfPdThySYKz+ZgxVXy3fNybPpkW5/6AI+ptzB EXVBKqj5B0zIHsXv7sOdc8mC/C/UbsT3fZLJna0INMue5vTvKdeA+qSCCXwI3UTOPGxK tR1w== 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=gxGZdWW+Li8qkcIOgXs3wSne6UlcSLwoVWi8V/kJIQo=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=COS+OrUNoch6nNTV4Rqz+jjzTnvuLZDLR2ZB1JaVU5cEoQcoDEptgFl/imHcjhuWRX BTdzcuxGF0eiUSsrWMKBK/X+h8m2ayo0mIKHp/pPuEQflVefxzOw6U87ucTdfRfHC8R1 8CEviDOwg3ZuJq/jOud9HGq6kvvDSVGR9ZU73zYAy/xsSBWWuwQccPLmx9A7B5QIuhJn NMaPl7keKj3QIsSMlRTE34KwB1dZ1SQnPFIpknpfO4zfZyJjN55OpNLHYzMc+zF5+EDK +Yh7wApFpF96m2+craZUtO+/i2qhg+CDcvqpqmJildmeAhSK8gLL1EnNy4CQvJhOHAs1 WP6Q== 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 jp19-20020a170906f75300b00988a0d75324si1347464ejb.279.2023.07.10.22.55.10; Mon, 10 Jul 2023 22:55:38 -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 S230306AbjGKFuS (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbjGKFuH (ORCPT ); Tue, 11 Jul 2023 01:50:07 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B1D11A7 for ; Mon, 10 Jul 2023 22:50:05 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771102470980644332 X-GMAIL-MSGID: 1771102470980644332 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: 118267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp267290vqm; Mon, 10 Jul 2023 23:01:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlE73QMZSHqm2iJtMr46YQLWjP/XPPYXabKgTPjvcBZApxZxNZrY1Uq/dEoJAPGMGNkLXRCL X-Received: by 2002:a05:6a00:1a88:b0:668:7e84:32e6 with SMTP id e8-20020a056a001a8800b006687e8432e6mr12782460pfv.29.1689055275220; Mon, 10 Jul 2023 23:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689055275; cv=none; d=google.com; s=arc-20160816; b=nGBAbBEAxKbtHLlEGAPfxrfJuhSeATFmA817FfAejxntwDIf78P/WrHN30OBQ2epc+ jevtjxHGMmAonFAIUA7IDEjYBZpLxLnknd6nV9aLTlf3BqDzadu0jAB2kTmJX6c36vLv 7bCU919GIjdpRmGx6qDs9x0iKyixjl9NTsEmbilxzQj61mDwy/s/VbCpOyseISYt9546 jZ0E3ekdzKT5POgraXOS86kcul8qgnYozZQ8Y9WNev5aiHOcz5ZRqVWnOQ0oAG0lCq0j +1rYAYcP3WTlpMzSK1E7Eq6/3qi9RdF5ss1GcV/2PnTiJPtwUkPwYGkueAxOA00o2Fyr QuPA== 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=2i79xieMi9enExQ9bAawHZrT03jaNr+fM2Du7WQiXQU=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=Yim01sK43vh5UDSxRKuMwh7mHbQyVjrXFzrrtCFf289n4aytCNqbPRzDjEr0MQn+8T OKrPvg5ayGO87r0likaALdvH5wDpiaE2PtACzC6hVKqj4/4RcFkM3kU69DyBcrI98nfr NeLNCZEvhBWLVZ8PysRzRUWoJ26TsHI/ZMACIh8u8TVLxzE43wf4Ju+CgsGcx+KMc/oN JSooHzK8v21RUd9rUpvIsiE8Jtrwh0peo++GClLWj43qTRoGRzawTLqCbDULUXuyKGb2 PgA+wX6+oeAZ1QCjHIJJudoowmwBP/75qs8cBFUrz4UvZzUP1n71gpoD9hw1tI0VwjaM jkXA== 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 fc11-20020a056a002e0b00b00670ab28fac3si922406pfb.378.2023.07.10.23.00.59; Mon, 10 Jul 2023 23:01:15 -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 S230482AbjGKFuX (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbjGKFuI (ORCPT ); Tue, 11 Jul 2023 01:50:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E1071AC for ; Mon, 10 Jul 2023 22:50:05 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771102824141626899 X-GMAIL-MSGID: 1771102824141626899 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: 118280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp276031vqm; Mon, 10 Jul 2023 23:23:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAffqWC7P0YdiTok0tT5PEMnlLgCrnlBVETJwaqFA6UKqqb71eD++/lWlOhftCCpVc5Pif X-Received: by 2002:a17:906:72c4:b0:994:1844:c714 with SMTP id m4-20020a17090672c400b009941844c714mr1352518ejl.4.1689056616059; Mon, 10 Jul 2023 23:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689056616; cv=none; d=google.com; s=arc-20160816; b=U8L4u6/Q2pOrixDbIcnsiGdRxT4pJvvcjuxR9EAxixZ+2bdVBoPmwHp12Hc/2ZYwvI b8h+CG0kXxU3GgOFQpxnF4WmWQySJSpR0lWY5MbmqroJBsysp9pan62MRAKyuOC1tkpk a1p1mY4CK/MKM0ZPcE+Gtxf4+ow3cXA9eIij0t/n7x3vyz1fY35VTndmRh6TtcYPk/0D wDFGXPQD9ZdpPI3r5ncqPjHosJkodK714WIpZQjjPnlbuPeVbAM9TlYI5OAgdcksPFqM EX43xCETeczr/GSDMtjzazyaKxB4e3v0sI29nadi/ve2zo7sDBiEEugFAGObau5lYMRF 1I8g== 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=rtDDWy5lm1vMhjdZV6LLpaDKXMrheUjre6SI2saWdQs=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=AcaQXrfZ+cMDryoXEK92VQ+XpicR++ABtYBJba4GX+KiP/pobcKulHetlCwTlSuksV VGfPbc1G2tsdLEQ/XInFbESyw+3bZC/jeTMgkmwTZeGpqi3LH+deeEtfUbby3OGY0mb3 5rbUtqOOUBdP7oZit2xV5+L60AFJIgWF/3sYQdJi2X9La4O/9fgLo6Bg0ArdJZNZkv1G v7dhl/+7yMoROgwRjIV5FCliIvriOeof8PCVxgW80u064Hv8zwmwf5mRIFWQp0h9xU4R 46+lr239TGUBEpsADiUmvxSDm4Uc6K8o0FgGnN1Yl18Q0DzarDINI+9hjs3/4bhvO+cA fNRg== 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 m7-20020a170906234700b0098df03ffa69si1500305eja.421.2023.07.10.23.23.12; Mon, 10 Jul 2023 23:23:36 -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 S230507AbjGKFuZ (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbjGKFuI (ORCPT ); Tue, 11 Jul 2023 01:50:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48FFCE40 for ; Mon, 10 Jul 2023 22:50:07 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771104230430690028 X-GMAIL-MSGID: 1771104230430690028 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: 118265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp266496vqm; Mon, 10 Jul 2023 22:59:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqI+5IE1QUiMDeRZywcXNJwKnm2cvbFzc4cbOU//a406dsX/LMxEtB/gDLOcYVaUlbfaGU X-Received: by 2002:a17:902:c410:b0:1b8:ad90:7af8 with SMTP id k16-20020a170902c41000b001b8ad907af8mr28242617plk.17.1689055198906; Mon, 10 Jul 2023 22:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689055198; cv=none; d=google.com; s=arc-20160816; b=wPYyCR84D8OwNBfHb2dCrY/fvU89qAnlqYmomxqG/ySotO8xA7oTJ6z4jBDE9RaAWR d6EgDlg8kJskyoL9OI8EM3t8j7PPVGPICwH3Ya5mq9BqOGSGjx/ZWhOZnKoyGf8nrvq+ T9kVjAR5XzavF2BRYRDo1An3nR/WeSP+asGUOw6EVsttYoC9E2KqkEkEn+DF1Zt0Ih8r 0ncLIUr6viNsV9laAmuGLxGybk560cES9yTBp5tMxzQGjss/EFxn207lRaYvcFidiRxd EiT1/kqGe3s/QJgI4XK0wzj89BeH5LIecnNhW8pZFHnqs6xcCYNGa2r0rR/blgiFubOO WVxA== 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=IV0T4/Lz70cuW+hklOvSGRAWozfHSplI/Flw5cVKpWk=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=VzBXrpLZfksc8PeY/r7kkdtQUQ0qUPVMKsfeijiYvWzB81YdeWODaFFQfbI/S+Wzzx 7nscn1tuAUh5La7mVPDS+l3sNOnalB7xiTkepODDi3KAuBdo6ySJ17Ll5lHwx21Oj4WI GO2PQxWOrfwke3CwHUTBReV3a1Xv0fPTAIEM9qhX+bWZrpsunpdOgzlGivVVJjDHnlWE r0mHXHdVLENky4VbS5ldR7/HsVcKUTBqYPviSwN8gBCZwr6Xw9FOE8MlSBTM8wRYy0FY t5nQxYDeZBXs0hwJn5dI3luzx5mjMlvcxfVN7NjKuYUKOpcvC+Z7jzDulKchIRCGzVvf Rn/g== 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 z8-20020a170902d54800b001b3bd85f54bsi1026851plf.35.2023.07.10.22.59.45; Mon, 10 Jul 2023 22:59:58 -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 S231179AbjGKFuc (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbjGKFuJ (ORCPT ); Tue, 11 Jul 2023 01:50:09 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAA81BB for ; Mon, 10 Jul 2023 22:50:06 -0700 (PDT) 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-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: INBOX X-GMAIL-THRID: 1771102744053758688 X-GMAIL-MSGID: 1771102744053758688 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: 118269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp267525vqm; Mon, 10 Jul 2023 23:01:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZ/4ZJ3pfln2cEDaTVXBj88FJUKU/P/t1YIBZMNlVzqi6sHbwzN2BU+ZAMTujGDaA9xU8n X-Received: by 2002:a05:6a20:9383:b0:12e:c5fb:757 with SMTP id x3-20020a056a20938300b0012ec5fb0757mr23974391pzh.5.1689055301952; Mon, 10 Jul 2023 23:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689055301; cv=none; d=google.com; s=arc-20160816; b=ankENFTHnbcuqTZAwji+NgmJe4CHT8kjd2vg/OUY8/g+dxyAdQY3aJq+DF8I4YoVcw QiNqr+rFCul6MsA4g77r0mjNLJtibxXUzwv1O0jtzBXVyOEQHBRKqiJ2PMF4N6wUS/09 ZqFhKZ633Vr5sEMoloj0rFE2FdAizEg0PXafIVsSwIcv2h9g3OZgfoDIB3v2hPT43euH qOzzPHJaBpZejWBaEqXb9yWGgAtu7vSG/BxcpGet7KAxKUzXtaSJ9U5QPshTZP8+P7wF V9AF3KG6OYddS5LfMAnfL2VaZ9GkngyzOO0pWvE2zQa7LVjTdHjHI920OsKUVE1QQds/ BLTA== 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=kZxpc3LLQdKRwi1qZzsu5rtB5wD/2h93r2whajVTytA=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=Q9s4TrpCuooZdk+7VIfcvmeo3AoVURIQln6X2Rqe0DUwhwkYkNT6xGH94cLs4hmWTB jWACSFjvXp1+mXSnB6EPztPqsLTLDkXnkiBh50M7kc5MFKAvXPPTOXRWyRdTf2Wj+AU2 t1xmAyEwkHRMG4+5jN172orjt5hYYTZOWzKqUjycnGghaMH7fNPK70B+FuVnrSkOaLC+ +zaqlxBjc/jm96tE7Lkn7PTi43J1I3zh8Q95wDyxvPeDAJi37py6/nk1NVc14l36Q2wK 9QAy3xyxkc6O5px9/lBG+RlQls69RsKuvGwKzDOFXaUimynUiZQd6DCc6NUSg+hi48AZ nkFg== 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 h184-20020a6383c1000000b0055b52bc1cabsi855475pge.196.2023.07.10.23.01.21; Mon, 10 Jul 2023 23:01:41 -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 S230266AbjGKFu3 (ORCPT + 99 others); Tue, 11 Jul 2023 01:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbjGKFuI (ORCPT ); Tue, 11 Jul 2023 01:50:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF441BC for ; Mon, 10 Jul 2023 22:50:07 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: INBOX X-GMAIL-THRID: 1771102852280582523 X-GMAIL-MSGID: 1771102852280582523 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,