From patchwork Thu Sep 21 07:44:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13393707 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 2469ACD342E for ; Thu, 21 Sep 2023 07:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B67226B0179; Thu, 21 Sep 2023 03:46:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B15576B0184; Thu, 21 Sep 2023 03:46:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A045E6B0188; Thu, 21 Sep 2023 03:46:20 -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 922346B0179 for ; Thu, 21 Sep 2023 03:46:20 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6C7A11CAD81 for ; Thu, 21 Sep 2023 07:46:20 +0000 (UTC) X-FDA: 81259821720.04.8F3E02B Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf07.hostedemail.com (Postfix) with ESMTP id EC09140018 for ; Thu, 21 Sep 2023 07:46:17 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@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=1695282378; 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=5ydsHzT7tGpO+G+ATUtNBq2QvjNbDU45vaayLl6WEyk=; b=jdLOcK1BUxQLUP63G3Q8OLY1DgT24a4xWEe93bRcp3UbcbJteUlN3XSX+2m6t8TSJKN1ov OE+iQvSJmGtHE1OjeTIj8j8Yl14PGkLAyuChc8mER4GnQM7OpJktaAVZZQJt3nhgNDhq1k q98GYE2e/7/Gzfrm/p02XrYUt468YXI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695282378; a=rsa-sha256; cv=none; b=7D9he+5P2mPvQclXVh4EPUTlZdVhf2T0leUeWBYhQBsBC/pxDovdKvdC09Mf2xmkXTOHim CF+6e1nEpmlKsLlPsFxE6bkoDK002Z0KPXU6tstYR/RIIYYce6d2vWVgx2//lYRd6s4AJA tLa4OtsdRvDav6dDnpzITAGYJjbAjK8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RrnRc37NyzMlkl; Thu, 21 Sep 2023 15:42:20 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 21 Sep 2023 15:45:56 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 1/6] mm: memory: add vm_normal_folio_pmd() Date: Thu, 21 Sep 2023 15:44:12 +0800 Message-ID: <20230921074417.24004-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230921074417.24004-1-wangkefeng.wang@huawei.com> References: <20230921074417.24004-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: e3xbaihk3oshpn35fqerhqisn8b9ejpu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EC09140018 X-Rspam-User: X-HE-Tag: 1695282377-407276 X-HE-Meta: U2FsdGVkX18F+sBW9CO68Rltk9z0p/G3XcBycqbxbX3KmTGK0fJI6blXaH8U/39cfKVAb3709gq2bVxea59GrUrR9RRYseD5VmAcDyJ3m81Yg2ramdn253OIFFWpOjsGLF+bcez9HijoKRiIqQAiHDauFWaAp42DoWQfcBQrtbsDGhQBrfFpVbUjiBVixmaCGZrhBw3ZFZoXsRTGeBK8vpR7oFUcxCJMl+fLVeSJjPGti0c4EcnNeQJ/2XbyIgOnzXoTm7aujrH0M01jHDz+weZw2VV+EFqt5Y9p2QFv95ndlLAfwKPJxdpon86jw62tPo6gm6xAqheWdpicoE9q4eeGffdlhJnalwsDDgMlCwQTWQ4IhnIAmkXQ8P/vBOrcyE9f0jcn8BaNEOEnV/11H0seIh9TRGAD63ZksPYE4Wt7pKd/tmoUNZzQfy4jgnf44F76WEpgx/Sq5nnhhUkHDGXmw8wgNfJ2mDmvfWhxjowi6XzxFeY2R5J1VzaVqqzdw+3Z6rwaI7sueiKHJVUsFEXBFQ3dnSMpzEZadhpcHbps3aQwjXY4crU9harY+3Rn42W9SXWYoWVU+TyPhmsmhfrmDVC/ymMNn4Lp7lblYbAUU2RVaAX7IbRbVauZTt7MMA77c+ohdbZY04LwbeTby61t++vCF+unD+nfc6FiKSkcB+LtdL1NeRlSm8nM5dcRh8f5igv/qm0QGyKKgNE0g+z+8RAmwQDg70KhYHnsPP4Am3poslhW4C7PLEjot8DkyouuGvDzOiOFfuSBV2nA/YRgA/8oahXbbmxLxzsHl2nmG8NsfQkRuTSW/HdEQeb+ANpg6LZK2C4NlowMyeTn2NBiffUnczmfEGnU+zOr5weCYJnYsHhjWdg0FAgcuLd+w4sx4vluDNUNnqOumjwOIRf0Qetq/4TuJUatFTIGxzv0fzrAa25arHeN/fdoTVVVpdbCkDpXYbWOPvD947H 84kZEpZ5 +yvq9hl5xdDmZpEwPOPvupakprNiQpIW6QPA2sgt62yZ+f3fnyEyE7sxsazF7gEWFLErKtj185HdVrAyq4NO4MByJjzeXJJDERyp5ipLEl8AUpsaYuNny2B6Vnj3Mg4qScGkaRmS29YBw6H6o5qCb0b4mvf91OyPmgYhsXX42akl4V+IPUP5HzKAFghOTP1CufjDI 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: The new vm_normal_folio_pmd() wrapper is similar to vm_normal_folio(), which allow them to completely replace the struct page variables with struct folio variables. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 2 ++ mm/memory.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 1f1d0d6b8f20..a1d0c82ac9a7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2325,6 +2325,8 @@ struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, pte_t pte); struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, pte_t pte); +struct folio *vm_normal_folio_pmd(struct vm_area_struct *vma, + unsigned long addr, pmd_t pmd); struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t pmd); diff --git a/mm/memory.c b/mm/memory.c index 983a40f8ee62..dbc7b67eca68 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -689,6 +689,16 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, out: return pfn_to_page(pfn); } + +struct folio *vm_normal_folio_pmd(struct vm_area_struct *vma, + unsigned long addr, pmd_t pmd) +{ + struct page *page = vm_normal_page_pmd(vma, addr, pmd); + + if (page) + return page_folio(page); + return NULL; +} #endif static void restore_exclusive_pte(struct vm_area_struct *vma,