Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2353791rwb; Thu, 27 Jul 2023 06:09:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4MjljHkoJUWT6npWLEszsuA4IR4EHKK9tS9LfjeYOI8Nb+cXdn7KYPJ+M7FABE3C6s/Bo X-Received: by 2002:a17:902:d2cd:b0:1b8:6cac:ffe8 with SMTP id n13-20020a170902d2cd00b001b86cacffe8mr5870514plc.51.1690463377599; Thu, 27 Jul 2023 06:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690463377; cv=none; d=google.com; s=arc-20160816; b=OdckAIcJ4ihVPKrQCBet4gz+2V5yHVT0zzLwyI4oFIJr03QuXrLsOAn0iVKhYOcvRN DoJP9sdzmk3L6xYtIJ8//zAKeOys1s5O47Hmv218ubYTgCJbsfb1GZshFmMJvqiZ0Pp+ 2gbNH819etPnVc4+g/DTyyqpAYxaLejfCqBA6HgjvgSjXKjkx6BUNFRo8bqnV9B/Ka5f FoUyZKuJ1zt3Na1IGl+mNGnsjquzb+8yWDJTG/EvEmdeIQy2WP694ilhx8FRY/MyVQqy PARpnIjBZQIJKcRHtustUZLbZXX1cuUqEKiXS7AuZB4xJzy6+iWVogR3Q/3Jvu/YCHnf Y0vw== 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=4nI5Th4Lolt/vdprRi+7d6+NL9neMGjB5HZ5+RCajoc=; fh=eUbl4v09I/Ha4OhmJ6gzDr/GCs46/1skqMRau+2m7SY=; b=fjsCDfx0VajQ/LHls3cgp6OgFDUBPvkXnrCFSphy0GthxbzKh7qTp5EQ/BrTwAbOqP C23NSY7o5s97ppawZgK9pQ0Q9NVsmHWAH/1mxrD1H8N+U8W6syyw4zs47Q2crmFBk8/O mIsO5i+o3Xe/pqDH0pCE8nQc/kN6aum6kW0sYoHV22eUNre5ukURfFE48yxMN4AvijHi A4s2aFPorRar0u3gMJ/JmAVDCv2c30IUd56z+shqjyWz/cU/FM+KZr7YhFofm3fpk5Dq PXEHfp55qi1VaNtWSaG101CydZoJycwT7RURu3cURjq5D4p0PJpt6HlzH6lHmabqJusx y9XQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a1709027c1100b001b88f151c9esi408363pll.123.2023.07.27.06.09.24; Thu, 27 Jul 2023 06:09:37 -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 S233384AbjG0L5I (ORCPT + 99 others); Thu, 27 Jul 2023 07:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233589AbjG0L46 (ORCPT ); Thu, 27 Jul 2023 07:56:58 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0F122D54 for ; Thu, 27 Jul 2023 04:56:54 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RBTgN0WB2ztRc7; Thu, 27 Jul 2023 19:53: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; Thu, 27 Jul 2023 19:56:51 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH v2 3/4] mm: memory-failure: avoid false hwpoison page mapped error info Date: Thu, 27 Jul 2023 19:56:42 +0800 Message-ID: <20230727115643.639741-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230727115643.639741-1-linmiaohe@huawei.com> References: <20230727115643.639741-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 folio->_mapcount is overloaded in SLAB, so folio_mapped() has to be done after folio_test_slab() is checked. Otherwise slab folio might be treated as a mapped folio leading to false 'Someone maps the hwpoison page' error info. Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin Reviewed-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 4a3e88c15631..d975a6b224f7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2535,6 +2535,13 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } + if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) + goto unlock_mutex; + + /* + * Note that folio->_mapcount is overloaded in SLAB, so the simple test + * in folio_mapped() has to be done after folio_test_slab() is checked. + */ if (folio_mapped(folio)) { unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n", pfn, &unpoison_rs); @@ -2547,9 +2554,6 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) - goto unlock_mutex; - ghp = get_hwpoison_page(p, MF_UNPOISON); if (!ghp) { if (PageHuge(p)) { -- 2.33.0