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: 164546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1276442vqg; Mon, 13 Nov 2023 07:22:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeImrZsEtMAEPVA9IY2OoJtDfc7+D4qfp1saiyn/j1CjB2QLXBPn/JpWj0oZRMMUrKqpDo X-Received: by 2002:a05:6358:711:b0:168:e68f:ad59 with SMTP id e17-20020a056358071100b00168e68fad59mr8178493rwj.2.1699888978599; Mon, 13 Nov 2023 07:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699888978; cv=none; d=google.com; s=arc-20160816; b=a0/L/0f7pth4IUum0wMh2SNAUFWEcyhOU++Zy32XdIbgHn00ECUdRmCCW7+rqL7YgR oC9OSylx+jErzBFiy/+FPddO0ctRzHOIe4iRicc9z4PzbJEiHDzM0Wal+Cu0joaCg8OR XW3vEhZLfDskqh0z2WqzmnhOhVv5ty0XUD4i/GOkg5L5Wzzy/gB58zVWbuMSWxEWa9zk M2LFcZH3Hv07EsbRvx/PLQe1TsPcy426zWL6PGBzXLqALk+Lbw6t8wMgk6VFY1obbabW jFJWnZPyMwEdKVLaY1LHO/IoscmIOncXmYzyOvPwYgbNQ03z1lg1DBbdN0ZHH2RbWUdV jZMg== 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=cAyyePa8XN8WBfh+8/yvfJEoyXSZBS8KmibjgbVY+F0=; fh=XlEU0c7GtD3y3c6Cq42Wb1IF2okvB16VXiKMJsE5Xwg=; b=UD7Nqwoyi66A2G5xoGda0hvArLSAGyUMDwiUBTesb/rcX4iY0Wjm1TF66zHHxH6dEb GjiKCeDXNjXelJIxMNHDViJCYhG+9pFiL9GnWuffV1fhuor2aEFWuqCYouopSGbTcpiX eLyBkjmrsEeHeJ0NcJnyxY9c0HM9JzAgLdM22NWBUQFLJj2yvw8lsghaJP0BZgJZl+Fb +bcyF+henq9rTutFXIv34WL8D38VcTde+eUkC0HV+91vgHhmLDIaHMSca6jgQE5RqUBR ii2tZBKSDMQJ0l7TLsEaN84u11sIMBeIEnmOX/vsUuFTbMOqJA/DoKhY8nCUtgLF7xNl X4uQ== 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 x62-20020a636341000000b005b936900e26si5715320pgb.713.2023.11.13.07.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 07:22:58 -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 4AD90802BE58; Mon, 13 Nov 2023 07:22:57 -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 S231346AbjKMPWu (ORCPT + 29 others); Mon, 13 Nov 2023 10:22:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231435AbjKMPWg (ORCPT ); Mon, 13 Nov 2023 10:22:36 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C04D69 for ; Mon, 13 Nov 2023 07:22:33 -0800 (PST) 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-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:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782462785901034696 X-GMAIL-MSGID: 1782462785901034696 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; } /*