From patchwork Tue Nov 7 13:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13448859 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 F0E76C4332F for ; Tue, 7 Nov 2023 13:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8943F8D004F; Tue, 7 Nov 2023 08:53:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 843048D0048; Tue, 7 Nov 2023 08:53:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70C578D004F; Tue, 7 Nov 2023 08:53:16 -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 6324E8D0048 for ; Tue, 7 Nov 2023 08:53:16 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3E4F11A03DF for ; Tue, 7 Nov 2023 13:53:16 +0000 (UTC) X-FDA: 81431299992.21.D45B9F2 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf13.hostedemail.com (Postfix) with ESMTP id 058072000F for ; Tue, 7 Nov 2023 13:53:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699365194; a=rsa-sha256; cv=none; b=PiAygDkw7nih+5GMsx4levvJl0YjHetOME7vNiJDBvNGNJLm5YJEbnPEQjd5Xq9f6oAuSh 0parJRuKzjejG/iMTg0n1e+AN3RWmihFAAP6jHtqyeN6/dw52O5zYrFnF4Q7d4plc8hOey Cshc9NPehGRqWA60Fgzun2gEDpvM1bE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1699365194; 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=o/bOO/iT/aY0O2jI9Ii7Hy15Bd6THEpIjPe7/vUXFkg=; b=mu1ayxnhemN4jZjkryOGIh9I4K8MYFo63hoQaZ2a23RbPXWOs5do3x7z3R2BlaW3jVKgdr pIewwOOWHt2bPsfJBYodg6JukYSmw0ZEgTLcjOV8oEbOu8kcCVhncznPOkSKX4a1i0izv6 IG7gKXlFuqbevc3RXhERD5fDFaowrH4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SPqLK3Ts3zMmMX; Tue, 7 Nov 2023 21:48:25 +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; Tue, 7 Nov 2023 21:52:52 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 3/6] mm: memory: rename page_copy_prealloc() to folio_prealloc() Date: Tue, 7 Nov 2023 21:52:13 +0800 Message-ID: <20231107135216.415926-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231107135216.415926-1-wangkefeng.wang@huawei.com> References: <20231107135216.415926-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 058072000F X-Stat-Signature: ccsemjphbf1k67sg7om3b15hbwtz9i7t X-Rspam-User: X-HE-Tag: 1699365193-832502 X-HE-Meta: U2FsdGVkX1/TaVO0VS8tnxz1lRbwJuensjSjRJ3i6DECa0IZG44d6kB4jy6tcTxujA2dIKlM5qc8JUMhadrU/mu1Hzq4ZYi1Jza/HVuMxzOIGGDVyzA/xk6cVmG6BIOW7Ji5B4XTkq1ROdTHWZEcdQrd4VHff2SwsYFZSYKrQ13cNsMROjQAzbU+jtN8A39MjPZwcIYBYo7ceAqp4vHVdBuX0iDWHmXf8VgL7WHG/LhEzh5vvkbJ4pJADSe3ib+VHyTkuUDMZ1HlZ/GF7x5WZvtcjN+PPpgnKlSzmBzvsw/HTcQ3+Fc/563gMVZFoYiMiYAVlU2fsNtGnyalYXH/XYu7pBecK5ZUWX3wkYgS7YN4SY7JbjcEOY1p8XxPn4CoiQEjsMoB8P9emtrW7MvpKw6Clcw/hmxOU97NDfS79AcMKJW+fyOFs9nMzpaOKmZ4J0ZNoky2OblmpmJUgAX+qPd0qZoKjBmBRVVMquWvWLagX+XGZrIa8/fwh91Nd3Sx+V35yX40t2J3Q+jzc7OCSGgUW0S5DhC3mMbjuwxTr/q0QoJNiBZU/y0JCeJ5YahGPt0/sPmV/lJv/9C0egDAF5q10CRp1KocLibFLvzAiWEF3yzeqG35F3SgfvRnWtYMhscLkmVlN57IJtVEbnKoPYAwc3LhvJS5tE2NWS4QIWWPqPDcSJZ29/uTGtt458wz30eAp7vZwJ6529DGvEB23FHQ/arwNhn880YpoQqX8dOqFL7QgWUWixlKBOnjIGfcKG49aPSU7phdPHWTgYtr25L27ywGozpy9AjxrVIh8q3CRoK/J4c8GduioE0ulxNKnLnNLeczhM3V0LtqhxYUCA0cQD+9k55umhLP/bUnEH+Fv54XNEreOczHq3x9gO2Mp39pnWugJydlmS+MJSbFI9Rk0MdmeLxkYmocGYi4QF/rEUjTr9pH6v5w0GJXrtz28bUE29kE85h1NWKN78/ AcWYP++D F3xze0j10TkV+5d2di1Nsuu2Cmj8bVjkj5nIRlkNIsGV1AngfkTp+TZhifIrPIp6LDulOMaerWKlziBcB9OjYnS98qo9oWDtWy9kfNCzojVT0wt14F+9vkpNVTlOtqyBBLUnQ6dYPSDhRsqA5N39Mbl3Xo5HREsSM1V3LnSz5vc5sVM8lBEEF3OEoTbCpofUdbtim 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 should_zero to it, and call the vma_alloc_zeroed_movable_folio() if need_zero is true. Signed-off-by: Kefeng Wang Reviewed-by: Sidhartha Kumar --- mm/memory.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b1bff4d245da..062136d25da3 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -988,12 +988,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; @@ -1125,7 +1130,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) {