From patchwork Wed Jun 22 17:06:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891182 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 37BEDC433EF for ; Wed, 22 Jun 2022 17:07:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 367A58E00D7; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F086E8E00D1; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D522E8E00D7; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B2D968E00D1 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 872E13561C for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.11.F893618 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id E8CE2100028 for ; Wed, 22 Jun 2022 17:06:50 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSqVc69q5z1KC7l; Thu, 23 Jun 2022 01:04:24 +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, 23 Jun 2022 01:06:31 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 10/16] mm/huge_memory: check pmd_present first in is_huge_zero_pmd Date: Thu, 23 Jun 2022 01:06:21 +0800 Message-ID: <20220622170627.19786-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917611; 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=hbj21bdAHUOl7J2ZRs+7KEibVpPsfNhXgbPCP0m5NSw=; b=WhYTE01gYG8KOu/zKFsxKW0znQhv6jUUZoTcBC63NWd74yrDV0oFXO2oS9yn91WHVoofob /2WeR/7X/SG9TtnnQp0or+LBw3gNF9Tqi53Udso6wsiXQsFgdhh1/rz2O+9qA5Zta5MS/0 ux+NyQsLd/FiEj7BQD1LkHSaLXIZY28= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917611; a=rsa-sha256; cv=none; b=fG347q5pxiHThyk+tlwChTCoCI/IVIS4xV3KjiGJHRlpcvpkia+cJnt3sCFb4AGwFgfAxw 52BzH0qQfd/e+64DvNZly+PAIfPvlr6KqMjVODjBmW4HEENC75H7No6Im6B4lvVsg8e6/V ByNniA+aMafeI86jz7MAaQsKbKORjtk= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: E8CE2100028 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: sdf1ucui47pq174p1n4y9uqp54i89r79 X-HE-Tag: 1655917610-723865 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: When pmd is non-present, pmd_pfn returns an insane value. So we should check pmd_present first to avoid acquiring such insane value and also avoid touching possible cold huge_zero_pfn cache line when pmd isn't present. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- include/linux/huge_mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index ae3d8e2fd9e2..12b297f9951d 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -273,7 +273,7 @@ static inline bool is_huge_zero_page(struct page *page) static inline bool is_huge_zero_pmd(pmd_t pmd) { - return READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd) && pmd_present(pmd); + return pmd_present(pmd) && READ_ONCE(huge_zero_pfn) == pmd_pfn(pmd); } static inline bool is_huge_zero_pud(pud_t pud)