From patchwork Thu Aug 18 13:00:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12947901 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 94A11C00140 for ; Thu, 18 Aug 2022 21:02:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19CED8D0003; Thu, 18 Aug 2022 17:02:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 126218D0002; Thu, 18 Aug 2022 17:02:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F09608D0003; Thu, 18 Aug 2022 17:02:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DF3D58D0002 for ; Thu, 18 Aug 2022 17:02:33 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BC0F01A2291 for ; Thu, 18 Aug 2022 21:02:33 +0000 (UTC) X-FDA: 79813936986.04.D8324FF Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf05.hostedemail.com (Postfix) with ESMTP id 468311006A3 for ; Thu, 18 Aug 2022 20:58:33 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M7lLZ5N68znTYd; Thu, 18 Aug 2022 20:58:30 +0800 (CST) Received: from huawei.com (10.175.124.27) 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.2375.24; Thu, 18 Aug 2022 21:00:43 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 6/6] mm, hwpoison: avoid trying to unpoison reserved page Date: Thu, 18 Aug 2022 21:00:16 +0800 Message-ID: <20220818130016.45313-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220818130016.45313-1-linmiaohe@huawei.com> References: <20220818130016.45313-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660856315; 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=h8JOndS46/RcjgxrDpgN7LFg53DbMpjkcyMzE5PQBUg=; b=wsl/rwO/ppDKgpDL8jaKpbpF27EOtfk54jMs78o9CfO8/C78GiGgFTGzlX3N7tRc8raG/K qn2GDP48/CwHNRI+qegq96TjRoGzNtoL5MYe3vpuD9xlK4WWoc5mEhvwf1xrwPG9QqE0u2 ouXvDzjzCBZSi1mspjcYg1ylO9KVSJw= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660856315; a=rsa-sha256; cv=none; b=Lh+X0JRjbQHisFHOCVToQxkTFbH2+Vxi0OpgQFDf4Q6ciZVnjyoCFMdESabw5FpN4v7xTB xiAhKHMEehlwZ7uPhcyZObH2o5Is82Vgi9J0C9/RkcOWvUJKP47FY/D7wVvZcwUJgj1K8B z0NIgI4HDGB69NuqyQcGrowrApbmCPQ= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 468311006A3 X-Stat-Signature: pj7irf6pxf5heqzb4a5b79swgr778bw6 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1660856313-682331 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: For reserved pages, HWPoison flag will be set without increasing the page refcnt. So we shouldn't even try to unpoison these pages and thus decrease the page refcnt unexpectly. Add a PageReserved() check to filter this case out and remove the below unneeded zero page (zero page is reserved) check. 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 5f9615a86296..c831c41bb092 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2355,7 +2355,7 @@ int unpoison_memory(unsigned long pfn) goto unlock_mutex; } - if (PageSlab(page) || PageTable(page)) + if (PageSlab(page) || PageTable(page) || PageReserved(page)) goto unlock_mutex; ret = get_hwpoison_page(p, MF_UNPOISON); @@ -2386,7 +2386,7 @@ int unpoison_memory(unsigned long pfn) freeit = !!TestClearPageHWPoison(p); put_page(page); - if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) { + if (freeit) { put_page(page); ret = 0; }