lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231113152222.3495908-7-wangkefeng.wang@huawei.com>
Date:   Mon, 13 Nov 2023 23:22:22 +0800
From:   Kefeng Wang <wangkefeng.wang@...wei.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
CC:     <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
        Matthew Wilcox <willy@...radead.org>,
        David Hildenbrand <david@...hat.com>,
        Sidhartha Kumar <sidhartha.kumar@...cle.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>
Subject: [PATCH v2 6/6] mm: memory: use folio_prealloc() in do_anonymous_page()

Use folio_prealloc() to simplify code a bit.

Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
---
 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;
 }
 
 /*
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ