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: 164543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1276330vqg; Mon, 13 Nov 2023 07:22:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZP/Lh7lRYxyTLBHRHNp0+k7Zei1mecsO2vrL+5kaMgATKhzSHprrcpnLbARKEcUqoIAgx X-Received: by 2002:a17:902:dac6:b0:1cc:42d0:dbc5 with SMTP id q6-20020a170902dac600b001cc42d0dbc5mr10278919plx.13.1699888967443; Mon, 13 Nov 2023 07:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699888967; cv=none; d=google.com; s=arc-20160816; b=VPFl0Oc6neRV1htJdWhcpx//vvCnritWbQGXGrvhVj3amJCU56KAMsdvHQIM2cMvpR Elbr65fDX2h3H6yZlnUwS5iKVz8f+srhe7SLxBgfqR7gPX4zQ1/rUvvKP7O51w4tqXtI aZnxS3p/hAhlN/p7Fd71kBkrWNEpPXE/qIyAocu1A4G2TqS0DoPASKTq2bzrMaNDBayr q2K013xPfEOlcAWPoqNp17SLB1+mqiLW2AZP2Pshfb1bDHIpOgPkCDehOsj5+99leAzk mpQ8uo6A/UnPJhknJZLdwA/rkQ8GY/Toz008gQAicnjaPE1yacYsUom4qAGBsE7TWvQa XTbw== 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=lVGmNv6TVFFpogWe6jHaLAKoD6Dw+UJho1vUDEoTmtQ=; fh=XlEU0c7GtD3y3c6Cq42Wb1IF2okvB16VXiKMJsE5Xwg=; b=tcrltE26iJ4utNb7WC1AHpEEiIMEM14hTgPN/XLxpmWGtDVLjoPYSjupLYkAWD2BIg YFEkw4bTbwyFGq13iTlP3EsAsFxjcfXN6K5VdjbDuXaD+vjRw/FB6puB0DhFzKSyQM8v 1H49pDSRbY3qBTdcFkCo6kt8kDdd1S2YpWHIYSULwFhSyC6J91ql2GkV+GQqWJPY7QOd nJA+VB+q2dbI4EsRN2yCzkKXfDF3ImIic1WUlmNoh+4eVv6xSMNlLyQQRmWYEsDZqGJD 94sqYP+5i85oWQ/wIhGoMv/SZVs8JfUmeyHMliftco9jRRx/icNvJb0RgKo3SzLw4mwq mVDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c11-20020a170902c1cb00b001ca7a4c8360si5663622plc.31.2023.11.13.07.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:22:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id C37C2802BE58; Mon, 13 Nov 2023 07:22:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbjKMPWm (ORCPT + 29 others); Mon, 13 Nov 2023 10:22:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231372AbjKMPWf (ORCPT ); Mon, 13 Nov 2023 10:22:35 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E200A4 for ; Mon, 13 Nov 2023 07:22:32 -0800 (PST) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 07:22:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782462773644997637 X-GMAIL-MSGID: 1782462773644997637 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) {