From patchwork Sat Jul 15 03:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D318C001DC for ; Sat, 15 Jul 2023 03:17:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C8A76B0075; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52C068D0003; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419D56B007B; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2D8786B0075 for ; Fri, 14 Jul 2023 23:17:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 08E5D16037D for ; Sat, 15 Jul 2023 03:17:31 +0000 (UTC) X-FDA: 81012385902.22.9AD9C33 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id C8E3F40002 for ; Sat, 15 Jul 2023 03:17:28 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689391049; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=de3/uVI4BBSVuMe4i98/EN3DRFaqVu/lA8S64yZitTk=; b=c4zd9NDVS/wKAkA6jEfJ7mmMzB9VujYbbyqKr7t7ADWcJWNxLG1mZKMRSZvB2ZaOIJVchs wpcclQSHVz3aK4Q2MZsmwF4rg9rUlp35H5LEJf6Hprl86I7xJS43PEXcFmFfydnWVlLJeF yqGkkfrUexq3wPtkaSBQrlTthDZzEJ8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689391049; a=rsa-sha256; cv=none; b=LEhPFHJqKWPRovk+2u4kgdB32igjunMAqCqIoiJjCnZn4q8UbQMK+f1Lg5ijj0ypTMJGmV hzgGN0rjQ4kb7wmUd8zEr6YpamtP8kRxQ2LrPxx5qOC8QUVkinNtQ0BIBIQAi4aFZBxG88 QF83J9v2Vh3v8XasK3JL4f4rLc92vQg= Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2tll6TXPzVjRT; Sat, 15 Jul 2023 11:16:03 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 15 Jul 2023 11:17:20 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 3/4] mm: memory-failure: avoid false hwpoison page mapped error info Date: Sat, 15 Jul 2023 11:17:28 +0800 Message-ID: <20230715031729.2420338-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: ba6rn7aqpi8dnqdtm4qkk7gbrwtiqeb3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C8E3F40002 X-HE-Tag: 1689391048-483991 X-HE-Meta: U2FsdGVkX18F198116rFZ2MMMlywIRxtaAiZUpU1/ZYvuz49cB9ap/X7yfoRNadKr+wgQtzKzjg+1jo/eIkWUTOD2kJt0VyksFmPcayxZQaKULUBQhzEs7xdYyqHCf1rbEqPRH++f7WmxP95NxgQa1BYJm5Lt3CfGY4BGzaoG7s5Dbs/bh0KEsymobYjfDuZ1IBiCHjO6GOgPfbEzC74HuZeZlV0DrxjPUsekfvjZWKbc1ij7n+AfrbGmSOz8m0inJoDxrTOXHVNyPEKNt+oKkRrx7nZEEA0rxwx4KRKnubxWyDlz+LDGUXbTe3zzBmtfUPm3XliH7HFO0rHdzg12XDcX265Bt5hycoXcIl1cxeNskwTL+8dk1AGRtmSyqgyb9a9lyMjp8sdUw5tJAXTZ5Au3ilSYo1+rif9UrGYzNoppH11gA+gSKVApefHSFbMNGBSGBgLZVDt1QBC8kSIro7qX2ut41gblQ4cdQ9ySWuon1h/gV3vENtSskWVtmdyviRCIdI6ncFSxoqQsQU7u07ymOE4nGDHAyxZLVa/2mz8Ljk0PI4bPCi7m7DPgRLSpKLBP1XuuMdD30GgRP8OYJl0waCAkJnKRRsE+3rgDlqLtUmInw2wnOkcPQksZinYwJS/e50KBkahmoNRK0ZXA+/TLBAk2dhApz7qA+8cFG7lGi7exoT/qXRRtJlnCwxQ9BQL8m19px9jLhgrWf5cdHjnXkb1Altl7/JyK06iGeFJZtdS7yYO2UneaEAwwW5FdnAIn/CTW75IlFRf7Zw5rVyMYzL82lgmcWm3Vc/pqp48qmjIcg1vVrn54ET8HooIqQN551mOcwmFuv7M86ENZKXwfX+iiEhnnnzPDFqawq1hOgtwnos3QYzmplM/DP4MCnNSkIvwWO8sy+CbKswscr5pBFwESz9rWBt432POXLI6P94kb6f7eNRWemAYYW2smsHHQVC0DA1cbk5LboW aCr104HN RH5qm2UkAZlxEbOm5mvbxwgOZ+1xr1Ffcguue1dvHQbw936vtaGNIf38/mX+h3v9HfW+FHVgjTH2nY6zjMaxZFFqc1cCuHSJNC8a97eo3b5xlSuFMl/6jyDne4zGU4Yr6YH2hwnFBEVGuPuY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: folio->_mapcount is overloaded in SLAB, so folio_mapped() has to be done after folio_test_slab() is checked. Otherwise slab folio might be treated as a mapped folio leading to false 'Someone maps the hwpoison page' error info. Fixes: 230ac719c500 ("mm/hwpoison: don't try to unpoison containment-failed pages") Signed-off-by: Miaohe Lin Reviewed-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ac074f82f5b3..42e63b0ab5f7 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2513,6 +2513,13 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } + if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) + goto unlock_mutex; + + /* + * Note that folio->_mapcount is overloaded in SLAB, so the simple test + * in folio_mapped() has to be done after folio_test_slab() is checked. + */ if (folio_mapped(folio)) { unpoison_pr_info("Unpoison: Someone maps the hwpoison page %#lx\n", pfn, &unpoison_rs); @@ -2525,9 +2532,6 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (folio_test_slab(folio) || PageTable(&folio->page) || folio_test_reserved(folio)) - goto unlock_mutex; - ret = get_hwpoison_page(p, MF_UNPOISON); if (!ret) { if (PageHuge(p)) {