From patchwork Tue Nov 7 13:52:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13448858 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 4E0C1C4332F for ; Tue, 7 Nov 2023 13:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD8088D004E; Tue, 7 Nov 2023 08:53:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C88798D0048; Tue, 7 Nov 2023 08:53:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B51118D004E; Tue, 7 Nov 2023 08:53:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A70458D0048 for ; Tue, 7 Nov 2023 08:53:11 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75B31C0A75 for ; Tue, 7 Nov 2023 13:53:11 +0000 (UTC) X-FDA: 81431299782.29.A35F469 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf28.hostedemail.com (Postfix) with ESMTP id BB9E8C000A for ; Tue, 7 Nov 2023 13:53:08 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699365189; a=rsa-sha256; cv=none; b=HPyaoCSZu3Emse1D0Vp/6JRJtrKi+YAOVnxAa4mZUk+xnG0diNJ03RllExWI5CXJP0OsyK 7nw/Zp1DRWCKv+cRz/xB2tkvf1GDKuqOoLbYkSOZ05DTpyPVKfvgi0fXSk+8lOhlUCLYmP JfO94z0ijNBeb+NM9qDen7g2LjWc38A= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1699365189; 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=3TkOrwGZP87VMhuXV/FwrvgOskqAkv4G8QWHfmrtDnU=; b=lU69crnKmuVZ9AmbDw86lAxzkCOYsnSg4rRsxmgKzGGJJxjrcZCViMRtuiBqUau+Zn41dB y6q9aX/C5NnhevY9AwlCWtSpwkzQv0HKvI+BFG/nd/0v3keQyRR80fncWvLuIqG5FoaVGr LBrQSpW/2N6fss8oI14GoloeBn8p504= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SPqLL4w68zMmNZ; Tue, 7 Nov 2023 21:48:26 +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:53 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 6/6] mm: memory: use folio_prealloc() in do_anonymous_page() Date: Tue, 7 Nov 2023 21:52:16 +0800 Message-ID: <20231107135216.415926-7-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BB9E8C000A X-Stat-Signature: y5yineso1kar5zm3rur1pwfcefpxtinf X-HE-Tag: 1699365188-910248 X-HE-Meta: U2FsdGVkX19DG/5zXl5ET3BXQgS0q1hZlRh0It9gzckHKOB9DENiTvLOA/SGbxngdpNvyY3V/OOsAQ6IQTtvBMvtm64g0xIB4GQDGmMN0KqXIgWN9eaBq0szCNduGn2y+dSJK19uGN5DWGLdIjslUrnUEPSw39BVhCR2050fnwEd4kzdYL9Du9R+qkOAOHXx4UfpQDwM6zOrI65hCcq9wS+dyFEmLw4AG+mbeDMd5dBaBU/8fFYpdMLa7e4uOmfz5JQ9zTzq3lPVaXcbsJhIRgFwV5W02rN1rCJbT8cYF40Eh7Uou8wdeSmn1HHw3ID11lLeV2+ExQbc+TfvhQpstUARaHMNSYiPWqbHJDLiNkpoFk9aHnaikREm2LF8AOCX5Y0dHFg/iuZFipVpFXId68LtCKSr8lRZFAxxq3PS2rZFepSWokKwJK5mYn+v8GzbmEHlhT0+CCObgdtjVhuNyUmp12L1JuXbLI7udYEzrHn72k3PciKAuQuhvQzSzRXgkKqMtkger1E4rsMAEeZMAiqJXpTO7I2nhWxE31iBe0kIo6IUW9P187QKf+IZJJSRFBmYjQJPnkoe0YP34Kwx9hDJvaa/JQ2v+F1DcANJURjPA/Oxtse/Fts8093c1vhfftxs1nzRUK4fsDHN+1J76S6WJRtC+KKeJZrgEq6wxA8sKvTTOfC3aZsJRmxFsOqMKuWeE7M+Dv7Tiv3awUXG2RKONPe2dQeP9csjL0DWB6dnN6FPt512R6TW5x0Ec1/DoQTUjNldm3TzhafbsbhEsMEciro555sf0BINGw8thc4goupOQZiz6hPBq3B+2SAV56yiF6wvSbnCxg2QszDFYKMINASz0Ggrg9dqpyWSCkacld3EGjoEcwToPPmitLOilL317AlDMEWpy9eGanIJpSwHlVS/3qo+Oj2gUCq73xt79ylI9aXHB2v6VblaInaRHzJSKZYsJi5AwGjrr6e FpYKraQ6 pf3Q7WB/sXlfBx7UOBUpvL0fDQuAmW0dUJ+ZeYwLxU1GICaS3xD5fwrT4ToQE0qDK83S0lod7S3iVdcZbb372uyKO6UDDYrnf2qg1gXgAMVyvnEeh8fD3hDyosP168n+JbX0utJSyBeKgtrL6Vuf2LbSYwY65ktV0oKQljU8Wp7f4q1Cx4Ki9oWuerxpBktO8b/dd 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 1a7dc19bd35d..e4deab750a51 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4167,14 +4167,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 @@ -4225,10 +4221,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; } /*