From patchwork Mon Nov 13 15:22:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13454126 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 CE25EC4167B for ; Mon, 13 Nov 2023 15:22:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E3DC6B0252; Mon, 13 Nov 2023 10:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 294A46B0254; 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 10F9F6B0252; Mon, 13 Nov 2023 10:22:40 -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 E36396B024E for ; Mon, 13 Nov 2023 10:22:40 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B13741208B7 for ; Mon, 13 Nov 2023 15:22:40 +0000 (UTC) X-FDA: 81453298080.21.B8ADFA8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 847368000E for ; Mon, 13 Nov 2023 15:22:37 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.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=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=cAyyePa8XN8WBfh+8/yvfJEoyXSZBS8KmibjgbVY+F0=; b=O4c/jxOamO9jdkxK02r+EKctztxFTFIgYbhVG4sx8OfKRfPQGZ1i/IIyv4HwhUvaPJLpV0 FKGfqvvBHKldIGf0fXrJDVcM4RtpsJ/umMsv/BhhPdCiz/qGYG2YzEF1zitfEDFET2Rnfi jUop5qE+Bv5JR6KDWtBIS8o94DIWfkw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.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=1699888959; a=rsa-sha256; cv=none; b=WCXHsluJwHWFiN6xCbHnotg3MYT6fCSG9jLpHrcWPvzZ+tJveZLifm2tIkbXPCn/TyMtQf CK7yHigM3nXiCgOywu3mUlv4ito8dg1GoClejoBM9BsSEYzDhprT1q4AOjXrgaPIXveoMU EmZtA9VRVxQiWOYOdAwyjWuetFqNUKI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4STY3H5H1wzPpH7; Mon, 13 Nov 2023 23:18:19 +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:30 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Sidhartha Kumar , Kefeng Wang Subject: [PATCH v2 6/6] mm: memory: use folio_prealloc() in do_anonymous_page() Date: Mon, 13 Nov 2023 23:22:22 +0800 Message-ID: <20231113152222.3495908-7-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-Server: rspam09 X-Rspamd-Queue-Id: 847368000E X-Stat-Signature: cgzw6temf5n81a6neqx5tqucpgaxx9q4 X-Rspam-User: X-HE-Tag: 1699888957-902359 X-HE-Meta: U2FsdGVkX1+6tgSBLlGVcj+jKHAxHH4dlKYdJXgc03/Wq1S3mtYQN2diVm2vVmnsLLq4Lmpc14+0OrwZjZKEh2M3um9N8VtGBNFRv7JHvb7c03B0AySktJPADzrHO2PSwZ1NJDN1CDdIg2Gi+wASvAYck2KVfd6s34ATNpdSrxMMtEKz+cZtoqrzrUj1TY81zF1gxL2J0CoaPNmTnZgP/ojclnzBHxa369po7O+u1Yvh7WuMgZevGzPlSvP+E0yefSLbWDg/lCdYHEddWsoAAOjpAYyxoDp9fiuwfr2stqfysvUz0uiQDVZyb1s9NXz/5nA/G8MZ52u65hxF6cglwxuGoxqoR/Lvf9/imF6YVDKroEFmGwB9UhSPCIoJrTB1DPhNcHEhKLwSoRvcpKvp03kS96zpasJlpo4t0EruLr/OmBNsj1mhrWx+UoGLqdICD+nP5IDXiQcHAuAkCVABn/YjemO6qp7hduVuC/pbqPQnEV5VKocRmbWWKhzxuUJ0JIkxLZ4OAyFYZky52kVDdENLweBMRlGzhQoEH4geW2cbVv6iPtH2/MwlG4t0QUr0gJrmH0v31tk3NOCyjHRdAieBEGYuj7IQMBxtKBH5qmlbg5fa3PJVGPX0mVSWfnTPXM7zemlUThlKqtPZ9z1SoYdSvxMeO76BEUUOib46KbNnfc55iYbUO2xC90nqA751lbkSe61LID2cTGjqTiAPkZRVVRD0C4OvJV5kSCbNpr9KmkkPn1DNiQ5S7LSRA6bHNntZdvzexHBZymfmj2iWGBZENKuEW2zhADiB8JEj67hMHKf65VUZipUmMFKBUOhSPyLGErO6dgs/MRWgn23l7OSQUJalFJA6dtpuEhjCFM+K2NNR01/wXIFq9ClpThkKkKTlK0GnAPjN6dBOrVACem/qEo8lFLUA9UAX/pap0ubc0St2RSQ2aLGJyqdYO1JHa4pgOHUkupIT+RDSF4I X0rdvCCK 67ba7fwLEhFa2/MlLRkNJdB4KBQf20MqcZMPsgynCLG2EzEEmrz6P8IkQAG4lTexmrzOEYb4DYFRZjuLNWao2Q64adWrdaRsw3ZiWaQ6YvRLwee9tRBcmhHYBE37DrJfQMQwyFWA5A5L1yJENFcPYaRjTazAU36vwlmwd7XjbX/9VR7nX79AY99xlbeGGSjbakZc3 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: Use folio_prealloc() to simplify code a bit. Signed-off-by: Kefeng Wang --- mm/memory.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 03226566bf8e..4995efbb6e83 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4172,14 +4172,10 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) /* Allocate our own private page. */ if (unlikely(anon_vma_prepare(vma))) - goto oom; - folio = vma_alloc_zeroed_movable_folio(vma, vmf->address); + return VM_FAULT_OOM; + folio = folio_prealloc(vma->vm_mm, vma, vmf->address, true); if (!folio) - goto oom; - - if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) - goto oom_free_page; - folio_throttle_swaprate(folio, GFP_KERNEL); + return VM_FAULT_OOM; /* * The memory barrier inside __folio_mark_uptodate makes sure that @@ -4230,10 +4226,6 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) release: folio_put(folio); goto unlock; -oom_free_page: - folio_put(folio); -oom: - return VM_FAULT_OOM; } /*