From patchwork Fri Oct 21 08:46:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13014445 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 A4E85C433FE for ; Fri, 21 Oct 2022 08:55:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE7558E0002; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C96068E0003; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0F7A8E0002; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9C0048E0001 for ; Fri, 21 Oct 2022 04:55:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6D92A81264 for ; Fri, 21 Oct 2022 08:55:47 +0000 (UTC) X-FDA: 80044348734.14.206F532 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id 2BC494002D for ; Fri, 21 Oct 2022 08:55:43 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MtyBd3zLvzVj4w; Fri, 21 Oct 2022 16:22:33 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:02 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 16:27:01 +0800 From: Kefeng Wang To: Naoya Horiguchi , Andrew Morton CC: Miaohe Lin , , , Kefeng Wang Subject: [PATCH 2/3] mm: memory-failure: avoid pfn_valid() twice in soft_offline_page() Date: Fri, 21 Oct 2022 16:46:10 +0800 Message-ID: <20221021084611.53765-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221021084611.53765-1-wangkefeng.wang@huawei.com> References: <20221021084611.53765-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666342547; a=rsa-sha256; cv=none; b=aKmJuw+LmUxjrwVrn7NWceRUH/H1IqdnA/ODiciMmwK8BAixx+txK3DKXi1L7qMtw+3NqQ Ak73dKWv//UCNe9pSf3c3Cmp7qNy7GAD9iNtHr2L4yIv9aoHz/r9Q8wwNg3MhcIWAusicP U+xyR5t9YwJL4XM/ZbD18pG+nIHuyKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666342546; 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=UU5kiPJznsCXvUnAokOkugtvK9CpUBlArCg9rxWhxEc=; b=3vjAerWbmBPvMokbSIr5YxXc0batd/WU8vI6LgV2P7D0xCc/reXisCRZdTxnCZQ6H+dR+l g6FGgB1Ybadv3aqodvzHIQCnlOk+7OO5eNGYt6LK1kV5tAn/HjwzW31OgPofaHmugJhfju Uenr+JqHuvQazugeBdnEv+7ZbojIdIY= Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: x456gc8ss1pkehir8cupnq599dpdpqwo X-Rspamd-Queue-Id: 2BC494002D X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666342543-662713 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: Simplify WARN_ON_ONCE(flags & MF_COUNT_INCREASED) under !pfn_valid(). Signed-off-by: Kefeng Wang Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b94152abb1c9..ca0199d0f79d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2554,10 +2554,10 @@ int soft_offline_page(unsigned long pfn, int flags) bool try_again = true; struct page *page; - WARN_ON_ONCE(!pfn_valid(pfn) && (flags & MF_COUNT_INCREASED)); - - if (!pfn_valid(pfn)) + if (!pfn_valid(pfn)) { + WARN_ON_ONCE(flags & MF_COUNT_INCREASED); return -ENXIO; + } /* Only online pages can be soft-offlined (esp., not ZONE_DEVICE). */ page = pfn_to_online_page(pfn);