diff mbox series

[1/7] khugepaged: Inline hpage_collapse_alloc_folio()

Message ID 20240403171838.1445826-2-willy@infradead.org (mailing list archive)
State New
Headers show
Series khugepaged folio conversions | expand

Commit Message

Matthew Wilcox April 3, 2024, 5:18 p.m. UTC
This function has one caller, and the combined function is simpler to
read, reason about and modify.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/khugepaged.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

Comments

Vishal Moola April 5, 2024, 9:13 p.m. UTC | #1
On Wed, Apr 03, 2024 at 06:18:30PM +0100, Matthew Wilcox (Oracle) wrote:
> This function has one caller, and the combined function is simpler to
> read, reason about and modify.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 38830174608f..ad16dd8b26a8 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -891,20 +891,6 @@  static int hpage_collapse_find_target_node(struct collapse_control *cc)
 }
 #endif
 
-static bool hpage_collapse_alloc_folio(struct folio **folio, gfp_t gfp, int node,
-				      nodemask_t *nmask)
-{
-	*folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, nmask);
-
-	if (unlikely(!*folio)) {
-		count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
-		return false;
-	}
-
-	count_vm_event(THP_COLLAPSE_ALLOC);
-	return true;
-}
-
 /*
  * If mmap_lock temporarily dropped, revalidate vma
  * before taking mmap_lock.
@@ -1067,11 +1053,14 @@  static int alloc_charge_hpage(struct page **hpage, struct mm_struct *mm,
 	int node = hpage_collapse_find_target_node(cc);
 	struct folio *folio;
 
-	if (!hpage_collapse_alloc_folio(&folio, gfp, node, &cc->alloc_nmask)) {
+	folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask);
+	if (!folio) {
 		*hpage = NULL;
+		count_vm_event(THP_COLLAPSE_ALLOC_FAILED);
 		return SCAN_ALLOC_HUGE_PAGE_FAIL;
 	}
 
+	count_vm_event(THP_COLLAPSE_ALLOC);
 	if (unlikely(mem_cgroup_charge(folio, mm, gfp))) {
 		folio_put(folio);
 		*hpage = NULL;