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: 6554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp565241wrr; Fri, 21 Oct 2022 01:31:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zzLGooJF9BzSBTgFhZlaOXtqrBetbW+iCrEk8wQ66ediNCYmiEiUeSiOppQW9To+d2Eip X-Received: by 2002:a65:6bcb:0:b0:44c:3e11:a7ac with SMTP id e11-20020a656bcb000000b0044c3e11a7acmr15712087pgw.274.1666341107885; Fri, 21 Oct 2022 01:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666341107; cv=none; d=google.com; s=arc-20160816; b=dazozBc4YLbVYGg3a9XXCEWZNJLH7wWUaAbc5OVk5j+HUfK2o8TBQhL2mCZH3H2h4D QPXM8TIknFtfQ24ndxzYycxQrWBXgl9jCtzyLmaGb+aQ7HDYqa22PehwdhkDMpyA0Yq2 wp/8vz5jxSa2N0OQtRXAQj8HLyJvKsJX6lZiWrylSO0kAXIu1Sr7uK1VOoQ0JfdZKhJa 96AjUWCfxba4/gUdXF/wGqFi6ho8/TaSfwu+KmCBs0PQGDoQND202Dp1786v+ZPtVwGA J9jLdFOehKaqFdlfIvCZdfhlgDehxxzV3j8bdk4exIl5CDgHFqku0IUfiRYdXx9EtSmA 1xBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UU5kiPJznsCXvUnAokOkugtvK9CpUBlArCg9rxWhxEc=; b=PLv4eeLEXxXdJZo4FTGGQIgdHvxJEx45fPs/hXtaj0H3v5H2/N3JeM6p3mzkuJVdF7 tRopMGXwRLkDCzcET3PlZeuK3SOyxp1kqjDv+9e7of0UbT4Uu5ct+MDcGwnTDn0pcEby lpLdpvzz+BqAV0G8kMDtVgwqMhs5jkL0FllCBI2HWSlREZeS6/n4/dyXKA5sauu34dqu JguSWXXls5Y+nqe4h8JlAsK9n1IiQ4V/THIOn11kP597t/HFUZn1PM7oSYVxv71gV6cJ TJUAkAmiV/j59UmFjpbnpoq9u4IExo6K8pC3JguaSn8wFjq1P/x5r5g2ZD2KOMY49K8C Nmew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b0017a034f7246si29846055plr.560.2022.10.21.01.31.34; Fri, 21 Oct 2022 01:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbiJUI1e (ORCPT + 99 others); Fri, 21 Oct 2022 04:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbiJUI1P (ORCPT ); Fri, 21 Oct 2022 04:27:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0AB51FB7AB for ; Fri, 21 Oct 2022 01:27:14 -0700 (PDT) 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747285293629528626?= X-GMAIL-MSGID: =?utf-8?q?1747285293629528626?= 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);