From patchwork Sat Jul 8 08:57:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 117413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3795691vqx; Sat, 8 Jul 2023 02:00:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcJ40kOLyC3EupT4Y0ErMPI5xEvlkyyVKBSO/IqFhf4hxhfFTgqdoiblSUuQQvU4g+AZQh X-Received: by 2002:a17:906:5946:b0:982:bbc7:15c0 with SMTP id g6-20020a170906594600b00982bbc715c0mr5590903ejr.66.1688806804874; Sat, 08 Jul 2023 02:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688806804; cv=none; d=google.com; s=arc-20160816; b=sQ1wWY61n4F7/yaeA9qHE49nyh97I26FQrqqvOiPyxx5L/Iqg2So7Oc2CIMegiYTAP B+eKD1Oly3zpCi82m/qyLQRDvuFcQJwHPevfTaYBOhHZQ/6mys6iBruFslz3JCATu8KC eiYIfTA8Xw4UlDiYwAa/blf8S1GXj2V5BDEshZhzn1WnIyHzn6hJZTpvEgZjMV/GhgYx pRaSjMuDXXGQ5VpdCQrFK05Jf0xCwu0ynyV4tWt58rCEg6qnKp1AmdqTGitj0KwQTqcE ZnSgRXG4Psc/80KExZfibKsClRYFXaXvNBXwB4ih5syyJJZKjMjmjS9Jac16CLobBAre 4A0A== 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=LCrOy4OLsHpFK0OuO84MTfILpCt87VTlpXIdT2mKjQg=; fh=4o7DIXI/66oHEW09L3854GeQKXh9nrvBy5ZxENMFBvA=; b=ZYZ8d4fOt0HRsf3TrYLsob2CWfaW+7Cw8zrXud2khp220mK0stNePC8XUhz97ULO3U MHwqCfmwd4+pSWaRDqMnDZC4oTPZe0Qin7gfnDpAxTKbjizw+m7B0s8JST0wZX0Zmc9d ywnQWZ+iod7nCpR3t9Hrheh6HVRDICBQZWYI0MmYbKVhHw6WPILDatjgpMRnTeojx47w MN8M78YrRVFd/A2OnRVfMm+iYfattixNkb0ag83pZVKVTbSP/aaO7HGwAeecDuo0Q0hd 7nOsTj7gshd3x5rawTNQTRxwVKlhjUw9zeuIpWmGp3dl8cly6/LQyiWvAfiOVOvBC5Mm 18dA== 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 br17-20020a170906d15100b009932528281asi3197446ejb.579.2023.07.08.01.59.41; Sat, 08 Jul 2023 02:00:04 -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 S230143AbjGHI5i (ORCPT + 99 others); Sat, 8 Jul 2023 04:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbjGHI5f (ORCPT ); Sat, 8 Jul 2023 04:57:35 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881281FF6 for ; Sat, 8 Jul 2023 01:57:33 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QykcL4RbFzPk0X; Sat, 8 Jul 2023 16:55:14 +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, 8 Jul 2023 16:57:29 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 4/8] mm: memory-failure: use local variable huge to check hugetlb page Date: Sat, 8 Jul 2023 16:57:40 +0800 Message-ID: <20230708085744.3599311-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230708085744.3599311-1-linmiaohe@huawei.com> References: <20230708085744.3599311-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) 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,T_SCC_BODY_TEXT_LINE 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?1770842284202805780?= X-GMAIL-MSGID: =?utf-8?q?1770842284202805780?= Use local variable huge to check whether page is hugetlb page to avoid calling PageHuge() multiple times to save cpu cycles. PageHuge() will be stable while extra page refcnt is held. 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 905758af70f3..88e48a4801ee 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2621,7 +2621,7 @@ static int soft_offline_in_use_page(struct page *page) } lock_page(page); - if (!PageHuge(page)) + if (!huge) wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); @@ -2630,7 +2630,7 @@ static int soft_offline_in_use_page(struct page *page) return 0; } - if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page)) + if (!huge && PageLRU(page) && !PageSwapCache(page)) /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages.