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: 142816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5021702vqi; Thu, 21 Sep 2023 10:42:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhtWVaB4UKxmuMzmaoiIG/nbz4dkQfCJchQ/62jhqLQCO6YLEdMk/aEAj576BSVdxZ25An X-Received: by 2002:a05:6a20:5494:b0:14d:d9f8:83f8 with SMTP id i20-20020a056a20549400b0014dd9f883f8mr7053465pzk.1.1695318125946; Thu, 21 Sep 2023 10:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695318125; cv=none; d=google.com; s=arc-20160816; b=FpBhxzqbw6HV1qSz+LYAGuR6uwWKIdjMozdRfOK+1NKxERvusSZtYO2saCSnF5Wof5 ggJ41z8Wq8QSC7UIsePYsbMNWO9yPWtMhlChqtNjL7Brm8ctxeczgtlwdIODS9LVTIRQ HJHbbFcdXH5+bTy3csxTV4vNCdjdCekUXXlCd7zI4JlfuooqFZSvI75NKGqfOcY3dKGx IiKi9SVp/f6HHYLb0mFYPjyEYscm0IxH3U1YKXQQO/8f7W6ZxTA94NVSJK/aa4rcKR9T a27U2LBB5VDalB67h9xzfBOPyUnnasjFPn2Zi/lc1Kj9HavZBxy/KD/IT4IGxCJZW8T/ Vdfg== 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=5ydsHzT7tGpO+G+ATUtNBq2QvjNbDU45vaayLl6WEyk=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=0YkcYQoosiO4FeB/Slxa1kTlja7RqbotXRiHS/k27XGtLUFPdO/AC6z3kEc+AZ6QaR bpdRqhNPEk4V7O4YD2fOdkcvMEGWe61DY5a/WJ15ABqbeSxkO80rXf+lmmT4a1tdEdxT LY/Dal3uMTNgU7fE2VlYZB/aMQ75kxfDqHUFgD8uOFQJeK6NvKMY5HAKw1vzvOp5kFPk kQw/Js8Kfdj/S0mzJqh9SMmmodZNCmBTQPHcUk+eXE+GW1xDO0xhKl9jqKLSFr/1CJDL uZxYxML/IvlYGnFI9szHj/9iNeby65z8aHEMv2Xqjai2JtZwJweFxy7t2whOQ0x1XVh0 OEWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bs186-20020a6328c3000000b0056fbf327dd5si1691601pgb.131.2023.09.21.10.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 10:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7DCA580FFDA9; Thu, 21 Sep 2023 10:24:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbjIURXr (ORCPT + 29 others); Thu, 21 Sep 2023 13:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjIURXS (ORCPT ); Thu, 21 Sep 2023 13:23:18 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08242E55 for ; Thu, 21 Sep 2023 10:11:42 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 10:24:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777669898922884932 X-GMAIL-MSGID: 1777669898922884932 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,