From patchwork Sat Nov 18 02:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13459823 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 C6859C5AE4B for ; Sat, 18 Nov 2023 02:33:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 524BB6B0167; Fri, 17 Nov 2023 21:33:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AFD96B019A; Fri, 17 Nov 2023 21:33:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 378C86B04F4; Fri, 17 Nov 2023 21:33:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1584D6B01A9 for ; Fri, 17 Nov 2023 21:33:12 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D6E15A02CD for ; Sat, 18 Nov 2023 02:33:11 +0000 (UTC) X-FDA: 81469502982.02.EB0CC97 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id 909DCA000B for ; Sat, 18 Nov 2023 02:33:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.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=1700274790; 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=hH8nivyyBhFS9UGQPkDETitUwUQwg6IdsbxfmgHY0pQ=; b=t+e5YveYOMEE3cqU0u/1CaQp8eY3dJY6Tboli3mWG0fKFJm6lYqwQAvvBQRG5Gu1A41UrE 3Gvvw8P0Ti9WcY5rYsDubjSD8gV5i6tSQAV5LWEsPLxwmVk92WL8wh/cumVHYxZHsUCGwm U9gPBuoaMEKW3CSsqL2vNFw3fg6wVDM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.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=1700274790; a=rsa-sha256; cv=none; b=v6UDsmiZwEj1QMkWP+qskNzioJIzkCIXCFHMVfx2om1QDcI+KoPoBesUJd5r0OuLxvnSq4 smUSE7ISbKHgyxVulG6YIYWLm/aNtSSU4MukpQHV/QdUOfI/FCOYsbJsqWlOvCcUcWIN07 3w84UTNH7Ehmr8VSWzWNMh4cXAb3scE= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SXHqT3NS9zQjCv; Sat, 18 Nov 2023 10:32:37 +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; Sat, 18 Nov 2023 10:33:04 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Sidhartha Kumar , Vishal Moola , Kefeng Wang Subject: [PATCH v3 3/5] mm: memory: rename page_copy_prealloc() to folio_prealloc() Date: Sat, 18 Nov 2023 10:32:30 +0800 Message-ID: <20231118023232.1409103-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231118023232.1409103-1-wangkefeng.wang@huawei.com> References: <20231118023232.1409103-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 909DCA000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kf71du3gmogz671f38uxuqkcxziq81ax X-HE-Tag: 1700274789-341158 X-HE-Meta: U2FsdGVkX1+Xqm0xSmmSnjuC/9Zvew0xJbhi0R1T6lSD3Ydvb+xlLm+O/hLqTi10uEfH+RCl5Cwe0BEs7G6xysqKMAbntbRN+NI03NOSDtCwCxZ2iUan37FAFbRtTEHi9y2xpdp5tnoAZ+tS7WDUE5Wm6EKeK2mBn+74yF0ttOGQMCKKShAUVjIt/eRsVH1HZBSI8SYLEgRmJnSjulvCkCqoucAxeFcieyWfOcJkACB9dQYkv4KB/0egSd3dd6DLHMuVj/83IhPSiCvy8JkDroyVQkPtPhiKmEv6D4ZA1fBYLmQo8xNrsiuJ6vvHjVdhaJTbEsmi0Y1EzCIt3TDJH6aLgHKDTVIwPsfi07W9ZS5GOjeDvzJuwEvMYI15ebJJgP/FtypcU1+9KyyLbK/uYP0gVvQdvFUYEcxDCtaVcVfA1vyibtBETlZGuczj0FBq04XqEIiwCEY0jtboEq4pZH7X3NvUeOoK1PP+Dc4cmmcupWHa7uHGBwzmj3qpdEzd0VhLVs9XMBDrccqjaAFCUTeipKbxon0MRfK3Ztfj+l3IYY38hD/947OsIzUcca+glxitwPGo/xbUBzYbeOBO4eoQthp2EVsxQ9u3K9j5WvuKoDd1th9rN+bAfDEdkgJM77a1Nb1VafDEgDbz9YPoN7/dYxmNiROAxhZkzFM6JRA07oKyvzAPnSfL07U0F4LqQVDys2X3/kC98rsMQzgsKeVD7GfRhanhxVKY5o3Z9wdb7BafjGFpRoB4nL0RGzwKKCSeBAJJLFWxCpIYr/iZAqRrHjuy5vZbdAnbIKxJLH8/61x1BUkKdQnIyefhZdoUj/WTOzAqTkYaJVoadSCc9QDdnozb9DHz1388m4MUQwiKE1I+kGP2Cz3kVuCIyF6dLqKtb/rHURB1f6NkE1JojorW6yTlk00gsUWqTY3UygA8A1q72sPIgpM5IC00vA+BtAMxNVr6QSgDf/FiF8r l8x0PkhG ymUr1NSloCT7m4pgIeMslbJAvloqAQCuf4zqHAR2INVEY9d0DrHeJXS6JeaOc9uEWQiBRpM2m6uodglosN41GjI9RPWoMhAlsS5kJn5EWvSD2J/7S5PtrEpXwgImkaxcx2RQlLLrTx0zaZa/k0OCefW6SNFAtAbH6HYRvlvjLjhMRci528qI4Cghb00MrT2EPFaNBbA+vm0eomKBTBnVo2lU7gAcvQ88iXGHcDYA5Tlhq9hUn4GOO4Z72oarQLgqtWzyY/OSsYdsGxDGqYSvLpNiD2m7Kashqa0SUncxp7hBmyUBTwuRM8/hqJA== 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 Reviewed-by: Vishal Moola (Oracle) Signed-off-by: Kefeng Wang --- mm/memory.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index dffd39c9b3af..93c9ed01fc86 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -990,12 +990,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; @@ -1127,7 +1132,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) {