From patchwork Mon Nov 13 15:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13454127 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 299A2C4167B for ; Mon, 13 Nov 2023 15:22:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F39C6B0251; Mon, 13 Nov 2023 10:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 468C36B0253; Mon, 13 Nov 2023 10:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E0F26B024E; Mon, 13 Nov 2023 10:22:41 -0500 (EST) 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 116FC6B024E for ; Mon, 13 Nov 2023 10:22:41 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D3936C089D for ; Mon, 13 Nov 2023 15:22:40 +0000 (UTC) X-FDA: 81453298080.17.72F66DD Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 9051440014 for ; Mon, 13 Nov 2023 15:22:38 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1699888959; 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=lVGmNv6TVFFpogWe6jHaLAKoD6Dw+UJho1vUDEoTmtQ=; b=vPvs24wmp6bnp5tjBwp/KNk/ovijZVf6B8uqQ8B2sgD6tnHYs0Z6/U/Pzf/w5XyvATZm8v +mqqM9/fhzUCSHaItaKJcVGefvcj2wti+FDKNmKyndIIW9s0xj1Ehl0EwlTU5jbnpyuPzR TNlGXIjD9HkEYL3ZWNNfC8+dJmxqm4M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699888959; a=rsa-sha256; cv=none; b=ICTxA+I0hSeRtz8jKJZtl3V9I/GdeLRnn61bX42zRg/1lkacD7PxWDjoHeKXePY1purf26 n8vBmnj1efBcXQa44WRLhh3BV+KZRZRDxaQtMIwGDTQkagW5+9/Je7ogg0LdXbMA+g+oBE w2n8e6L0Y7JCjbxMMeeh4S5647mnTvk= 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.188 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 szxga02-in.huawei.com (SkyGuard) with ESMTP id 4STY3G2t3bzPpGB; Mon, 13 Nov 2023 23:18:18 +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, 13 Nov 2023 23:22:29 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Sidhartha Kumar , Kefeng Wang Subject: [PATCH v2 3/6] mm: memory: rename page_copy_prealloc() to folio_prealloc() Date: Mon, 13 Nov 2023 23:22:19 +0800 Message-ID: <20231113152222.3495908-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231113152222.3495908-1-wangkefeng.wang@huawei.com> References: <20231113152222.3495908-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 9051440014 X-Rspam-User: X-Stat-Signature: gtzd1fa4a7gte1sz5y7poqzn7tbmtisq X-Rspamd-Server: rspam03 X-HE-Tag: 1699888958-396338 X-HE-Meta: U2FsdGVkX1+erh7RmdtIVN0zFaAXw5jFSM5UYr1u4CzwkdTWyDwOFAlrCgiHpGJEQn+7Tjz3KodDDduvwtj0mRl12VtBJfjio/qOrKkPZXUxxajew5E0f9n0/kt8P3EC2Cg4IDns32jGTglJL0Sn9YM2MkBKAU//P0H0zJe5O0HX1UtVnd6qHM77SVWW1baNlpjFDVfVy95hsZIap3PTXTcg0s+AtnkOgXzdYCIrqVwFpv0iP6Iu8bU5NTFeHT8Bb2Ovqxxp3UgajLODLLej/LoOwXsWbypJwAb62CBq2ojzy4XQJuWXoPA7zqRFVQERCRvFww1G6SJ3KVQh+yKVu7bnNurkDuTL1IUnJRAvTfflM/7mRqV87iSMwTQf+wjqhqMB/MMq8PFln+rhdTRUjN7atso4RSAphZ97D/CVSVoP6XhryZViVUOhTVxOumR2ceygZ520gunia9b/R83ywXFK/nx09m0K6olr1pIQP+Z3l0ZfMkYmoh69UFMxx39usjEgL4GpehJ/HYqC7Jgxs6ttKK0eYeqGbSh7XVDa7rn+Hel6lpGqr3BUCbAlW47Uw7kOmQmEAZ8MmBRchrbPLqPLDrBi1UHJMDfINyHwlNpIlFHqGwCDG24U8jcpaLgaGyteC2NCXaMzbxXJzT91qRfmsWsA9NswcwZCu0ADVetTRo4ocl2n6B4nlV0fvGw9iCHIj4mnrP5TPjbROi9S1+AuDe9Q0LacK6bBdONN9YxzVBWHzwYSqz4HT5CCpwlZGj/evqtvYIX2L+F/vTvN5BNrutTGPmp1xh0XH/yEUQt48rgz/7ghbsnuaofM3GlnPK7+B6jYN2TEOaX/g/8znzalUmuHAhHLYOkzHFfBubqo4NQETqvtqHf+fV2w85l06uoVoBPN1A0qLcg7P3NgR5YdU+O0w9Uh9lNs0R06sfuUBYic+IxPGz4deO9PNH60Y79kbyPLCKHyA7u9K0V bxc4YtxW IeEhsxQ30/8NyyvrOpGJlA+xqtcAk05lQ6+yz7Y7Wilm5sl+35lPKVurf/fo/VgVdKFbbp0EbozX+sqfGI4RSmiDpQRYU3CTKbURBP0Tx0UP3bJbNrxYWRlXxCWzLU6X9u33K3qgsQjqoIVGYKe9o2F0vN8gL9e3IgN5eJ0FjH6+hjAzaMaYHAA+DVzbzfWPLJeKUJCRX6o9kOH5jOJXdrMxeeg== 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: List-Subscribe: List-Unsubscribe: Let's rename page_copy_prealloc() to folio_prealloc(), which could be reused in more functons, as it maybe zero the new page, pass a new need_zero to it, and call the vma_alloc_zeroed_movable_folio() if need_zero is true. Reviewed-by: Sidhartha Kumar Signed-off-by: Kefeng Wang Reviewed-by: Vishal Moola (Oracle) --- mm/memory.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 379354b35891..d85df1c59f52 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -992,12 +992,17 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, return 0; } -static inline struct folio *page_copy_prealloc(struct mm_struct *src_mm, - struct vm_area_struct *vma, unsigned long addr) +static inline struct folio *folio_prealloc(struct mm_struct *src_mm, + struct vm_area_struct *vma, unsigned long addr, bool need_zero) { struct folio *new_folio; - new_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, addr, false); + if (need_zero) + new_folio = vma_alloc_zeroed_movable_folio(vma, addr); + else + new_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, + addr, false); + if (!new_folio) return NULL; @@ -1129,7 +1134,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } else if (ret == -EBUSY) { goto out; } else if (ret == -EAGAIN) { - prealloc = page_copy_prealloc(src_mm, src_vma, addr); + prealloc = folio_prealloc(src_mm, src_vma, addr, false); if (!prealloc) return -ENOMEM; } else if (ret) {