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: 162511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp247133vqo; Tue, 7 Nov 2023 05:55:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQfpczFOpf9Hgk5LSsHsRveQ83IFCPsPNPooxmkZ+3zxc5TehJ5vnfyUhonsLi/LJLBC6e X-Received: by 2002:a05:6a21:7885:b0:17e:aa00:ca62 with SMTP id bf5-20020a056a21788500b0017eaa00ca62mr3946560pzc.17.1699365305323; Tue, 07 Nov 2023 05:55:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699365305; cv=none; d=google.com; s=arc-20160816; b=resMWZo6ZuVXo0M9dFCWkdH8L3/aO2mWM+unVmEj1Y0YwHlpJ61eLzU1fACVqT5BuP ohBxXGK2hwHSJdU8oE2i+XENURKEC845g5IfLyDeam2abuOenuYfb4QByoT6uauo1K7t 8UtvVdw/k+b6h/FnfjRYBmXmCfEnRARKiNxPriw2sbuOEKiOl+HBrZQgR9wYE9Fdtb/s yr2m5HP64KQdlublQTxkxkD94iMsnHITRhfj8kkz4ENPh+jFvO/xI1bHV66J3G0R1ASn 5d6YufvFBEfnJotZcJmZH5F+zIClNDrfzf9OoBqoj1/pDVYg8W22poMTo7PWOWOncngp y2AQ== 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=3TkOrwGZP87VMhuXV/FwrvgOskqAkv4G8QWHfmrtDnU=; fh=mT5bKTeask8yf/HL65t+eda2+hCp7isEA6/Uj2VbVV4=; b=VyLsEXWW4LDuXFdCuZeP8FVSqvh+KHqO4z7U31edmTKrLfhxfjg/e1hHmInSNDcBEQ ABReu+rgQJIkqxRZ11AF7nR2dMtNX109enW9EgMaNuE9Cjot2pIo0V5hMSSUwav4+FA4 TPP/if82bsgUdwdaWZGUdXfVgF79Khj2MhYagPRwQTWCxkgaGGUjo4ZxrvwD2jsyffXt dKlwknw67KGFvNhnwcKgw+oa2cwirsIT1IPv8GBlI6JVOTkRhYbJls0B2ifYahII0lWj kIYtrQRnrvuWfffExKpRieuzbxVgHwnAfSasdOadBJuaJqIb4rURWmkj7CgHdRlUAL1/ 9mAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ct9-20020a056a000f8900b006b54b82dac0si11058239pfb.298.2023.11.07.05.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 05:55:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 19A7480F7E5E; Tue, 7 Nov 2023 05:55:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234940AbjKGNyp (ORCPT + 32 others); Tue, 7 Nov 2023 08:54:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234520AbjKGNxc (ORCPT ); Tue, 7 Nov 2023 08:53:32 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B61119AE for ; Tue, 7 Nov 2023 05:52:56 -0800 (PST) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Tue, 07 Nov 2023 05:55:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781913673940651934 X-GMAIL-MSGID: 1781913673940651934 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; } /*