From patchwork Tue Aug 23 03:23:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12951679 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 9B7B1C28D13 for ; Tue, 23 Aug 2022 03:24:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B47B8D0008; Mon, 22 Aug 2022 23:24:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EB5E8D0006; Mon, 22 Aug 2022 23:24:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 062488D0008; Mon, 22 Aug 2022 23:24:26 -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 E58278D0006 for ; Mon, 22 Aug 2022 23:24:25 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C1B6B160677 for ; Tue, 23 Aug 2022 03:24:25 +0000 (UTC) X-FDA: 79829414490.08.B93C0FC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 4129AC0050 for ; Tue, 23 Aug 2022 03:24:24 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MBZHn2SrszgYpq; Tue, 23 Aug 2022 11:20:53 +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; Tue, 23 Aug 2022 11:24:21 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 6/6] mm, hwpoison: avoid trying to unpoison reserved page Date: Tue, 23 Aug 2022 11:23:46 +0800 Message-ID: <20220823032346.4260-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220823032346.4260-1-linmiaohe@huawei.com> References: <20220823032346.4260-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661225065; a=rsa-sha256; cv=none; b=szrHMfcDPkTKwEq6a2cP0y3zSygvNt+bmDCZHXYxH3XJlFHbRLodqYN6H9OpW+kI6EXA7Y lTEMH+lkFT2ipRFeQ4Jj8CIf7vIhbVPc47XwMqyRYLERYlNJWTMHtHGFGXnI5nYkRXd/SZ vWsWmrjD/2BHyWA1J+maZNAblQw1AjU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1661225065; 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=NVkGst6K526LP6oQ59e++PJ5St0Zj5qkPKrR+BZ33DI=; b=L9GcFoEaKiAz9JQ2o3YnWJtV9ZPkU5GMDqH+gPomHJQikj9AR0hYhH7D015KpU0KhArRJa hSkFZUPc9UXvCquokvCr/gXlwln8r0u2j+EqGwuELhdkVyFfZHtva6b0IG75iJSB47Cq2C +sprauMFvN1zisyWKAZuYo2lQB4jN6I= X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4129AC0050 X-Stat-Signature: gzwacjp57cmm4yuupezmmfyoh96u4qox X-HE-Tag: 1661225064-954575 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 c2910f9af1d4..f3ff2515ccc6 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2351,7 +2351,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); @@ -2382,7 +2382,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; }