From patchwork Thu Jul 27 11:56: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: 13330024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A770AC04A94 for ; Thu, 27 Jul 2023 11:57:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A32D6B0075; Thu, 27 Jul 2023 07:57:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92C436B007B; Thu, 27 Jul 2023 07:57:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D42D6B0080; Thu, 27 Jul 2023 07:57:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 49D956B0075 for ; Thu, 27 Jul 2023 07:57:02 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 164F81A108E for ; Thu, 27 Jul 2023 11:57:02 +0000 (UTC) X-FDA: 81057240684.11.D722B5D Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf15.hostedemail.com (Postfix) with ESMTP id B5A45A0005 for ; Thu, 27 Jul 2023 11:56:57 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690459019; a=rsa-sha256; cv=none; b=1KUYAbcL0MD6HW1QkbGxPVBwOPS9ZeK9R7sKgdYXZ/m/Nskbn9oy+6cguNbsXmEX+jQuHb ZegjV9zYNmx9HM18fVy++084uAbujAxE9KIKgtPVB/O803+nVzfCAovJiBvIZgJg3YIHxL JFtlfYXO1ExOG9o5ixfmzaD4wW7Pqdo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690459019; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4nI5Th4Lolt/vdprRi+7d6+NL9neMGjB5HZ5+RCajoc=; b=Cv4hBziprMJQS7tVWy4k1sJ4AbtAbl+pGpEjvEN0F9CViIgClC0Hq/jK/W88jzbCSryDJs gHhjp6xJgH7ihnmGtNvbuPa+7CWs+wi/yVvIOYPVWRkkjXzcmSB3sjKAfHdy8Rgi0f9ciu nMgyqhUnlRigIu/wo5/OeRpxOVEzxGU= 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 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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B5A45A0005 X-Stat-Signature: zpge9nkyaa4bosjquksmpfbs97p1ymgw X-HE-Tag: 1690459017-700258 X-HE-Meta: U2FsdGVkX1+ci03Hv98E7t1ECorJ0SE5ikj73tv/hSSsJtTEOAN0SOivNd87MH6G4uySKcUyAvFcORNPh5ZBvR6+r08lH9iyZ/Y5qExIcSvVpddtDAGLa3+a581ScgeoXlSJpBqFLz7c0ADY+qPvJ4EJZfO2mMeROpUA8J5lnmybzN9Sj4sE1ZKqtjlGnfnkgaE69zh8MWjvdLXTMY3NQZ8/gghoDnMF9I11IVhypnx2Lf3mPj0vq0nxuteqFEC+Wi/NYSMFpbM2jVoW/jIn2HApOG3kjmrCQvFsktK7KPeNTvRK9I1SNkokeccij1jWUFhiZfFnc632q9W85O25yegcOlxoyWgMQECHBiB6hOA3x0d7mrJJsJDn2qeD1KgFphdhmLn6rOSl58GVGOh5cJRLqpFaekIFh+p23tal0/9o1tN4JLhBy6v41tB4PO4h4UjZs9j8F8qvcCsc9w8SzJNxu+AISGvIRbQWEqsuVrO1AHFyotpkfDccGUSCKzhCHHvzwvK1aXPlbbdYVVJJEUMtdPUTjKt6sPAOTfDL94JuqxkD6CrXAtaCczQ/pYxV7LdisDx80lhCnqckhk2dYgjSXKDZzsLDgflVcfuUQfgCLstXnoHm9TG0rID91llKU1BPd4eTK6AsYK1pYNnpKy28/+RBY2DiMWJTfrXMsf59o00/w2d3GpNVH7oq66MuQsO8n0QUJDvythOBFB26mgRle906myLBXVgrMbQ80SZty4JxsLpTPmIiZVhMnbhjpzBKcSXOPWQEN8gX/od5tIJN6eHloSd9kDB3MHO+yS8d/7ro3skpTvKOAJJcMSQmtb5w+D7xrMU4Z6JLtQxE8I9sNl3Co7NCAvfmfSjxcCIF0cb8vSuf7t4F8CmYdKeCSqaXuzLWOZR1xXJzdJYkFyVHvMAgy9lJDgPPGjR2skkwk6FpCn52mhRKLdx0TkxL4dAifpCgsNyfsrV6Gre rYALbHAZ O5J+Npp761EQUfTI2nq9Kw1QDIRomWqhXumiQlBr25CktKM0Z0lh4pBhgkkCm5jaOoPCH7fbIfjt9tFpJUO/AFsbrBUb47+r+bLlbpYIr04qnaEFZyeNh1T3DbQJkOz3Xg9lp01aZf17wOEbkqPpAL0oGEVxqrZcE6gop0Bb5hOlL/GO+OzGC9FQwsDuIzo621tXKic1leAgdGw5FL+57rkqE6VUFTvFSpTqK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: folio->_mapcount is overloaded in SLAB, so folio_mapped() has to be done after folio_test_slab() is checked. Otherwise slab folio might be treated as a mapped folio leading to false 'Someone maps the hwpoison page' error info. Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin Reviewed-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 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)) {