From patchwork Mon Sep 18 10:32: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: 13389376 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 530B3CD37B0 for ; Mon, 18 Sep 2023 10:32:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCBC86B02D4; Mon, 18 Sep 2023 06:32:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C78136B02D9; Mon, 18 Sep 2023 06:32:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A092B6B02DA; Mon, 18 Sep 2023 06:32:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 81AF26B02D4 for ; Mon, 18 Sep 2023 06:32:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E722140364 for ; Mon, 18 Sep 2023 10:32:55 +0000 (UTC) X-FDA: 81249355110.04.CA6A4C8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id 88A2B40029 for ; Mon, 18 Sep 2023 10:32:51 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695033173; 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=Wep4XMTReQIGX+QGef6xN/N0d87XNkh3obqJUoMPMNU=; b=awNCRWX7rUi45MyP7a/cieRMrPbDwkXOikfP8mTCZDHLnCMr7HhpdHDzowDS6HekfhioyP EO8K0OXhizI48B9o9oqe2DiGnfF+4WtGhRNdtn7MDIW746X3neIF4E4fQer8MyipGs1Xzo 2W9DuFEy/ryoCMLKEJduBUk0h17Qtsc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695033173; a=rsa-sha256; cv=none; b=od3tFkGQ1J34g8cN87doKpeBuHdUtsxmcK8DcD5JV7xeWnTdHM/JHQFU17g+kJAJlApYQp MNVjr92OPId5VrLZgC6HvN9KsCcaiupJ7+8vse3hs+ThVyryJc8bm7r4sjwP09cB3GxyyS Gb31hL8z9U+sj848yAHcf1GhHtVMXos= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rq1JK6Y0RzVky5; Mon, 18 Sep 2023 18:29:53 +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; Mon, 18 Sep 2023 18:32:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH 5/6] mm: memory: add vm_normal_pmd_folio() Date: Mon, 18 Sep 2023 18:32:12 +0800 Message-ID: <20230918103213.4166210-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230918103213.4166210-1-wangkefeng.wang@huawei.com> References: <20230918103213.4166210-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 88A2B40029 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bb648wqo885rgujmji8krkiz77j5fkw8 X-HE-Tag: 1695033171-599830 X-HE-Meta: U2FsdGVkX1+aXBFj6BFPW5QHNnXnu2ok1/c+TJoaje9NkSBrhHPHRnZ6jX55xiVLqL2MHUnbjdkBQ8wNTYrmdXIXn8E9coWdrfmiw19AmJnrLSPRnGaRyM0G1kbXlmSqxUkVqQ6lJagP5ksDmhxqYtxYu+CAaKk/QMcj9AsHzPPqsIFIOtHv2S3QAJHKE6gH8riFsQjS/wtcVXjDbDfo4Wx67LQKfLw8wss7Y9u2O8W1LauLB86z1a59vohfsI4jeKV/wY5yBm0VMPLgPkC+B0gV4wOb/FHUGemOH6/0UnC8eKKAPue+n2e/w+B5zXm1KGuy5aVkCa+nPtLInO54d0d1p8XBUJFurLVD3sFGX3/8lH3fXQRXCQdUtXx0XTluZKGPil79+ZiPXkCjhlTZx83ZUrDuc0M7cRSTtmz5a0B7YGvToauQx4lsPBmavAzgtRi74x5ze6b4n4mJP1C2ldumuee6wwYH6jlFKCGhpG4DkVo1gdav2jyWdiTkAnpCm86eebYSHnOkHGppm15sTwuHrchY3ZAMowxyqvlsakI+RYkM8x5cS50eRYeHnz9/SG4lFompvUAXx/zL4r54GSx1DfBkPhy4YxLkER6ai65O/mIJZNdt+l2e4tUzPUu+PGUlJ6jgzbxnqrlJzDcxe4/Y44DNgrWet1dcB+98T8OU2Copm7Ek+vulG7+ZhmkbrOh4qwQw6eDRpU8wAxeKWw1T1kex6WEpLSQD1j8uB1n04APjd3DW3I5c/YSB3n3zF13+kYVTcp3Kbb/GamrKE2NqCmS/NBSsipaWJo/1a6ExesPp1vhFfR92xAyaIprjbESiuV/75dqY4a9AdX5R5qEi4S7GwFJUf2j53Vy9gF2GKWiAgnWNKTdIAMuMEQl2hcUH8DOqXqmsLbcbCCPYHEnkpe891mk/NvG8eNN8pqz6gHZExc5MLPIY0fPhlihP+9Cn5znbqwLWfBpxEP9 hx7GaLa7 JslX+u0Ld5ku+TTc60kTkgRiAWUySrkJU30sna0+FYgqJRnQ1KTuHDlKuzU6MfZX85g+MPohNkpzVtrireXtGFLynNqU1Hd/pFpP8krh45IQccBfRQ5OJXH6W8LHGc/QCqXWE40AtTpkJPzJxdiBlV89jjEAE8vVZdZYsaY5iEVC5fYiPbtxvlSVbyTwstjy1wfEC 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_pmd_folio() 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 12335de50140..7d05ec047186 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2327,6 +2327,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_pmd_folio(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 ce3efe7255d2..d4296ee72730 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_pmd_folio(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,