[merged mm-stable] mm-hugetlb-use-error-variable-in-alloc_hugetlb_folio.patch removed from -mm tree

Andrew Morton <[email protected]> Thu, 30 Jul 2026 19:43:05 -0700
Newsgroups org.kernel.vger.mm-commits
Message-ID <[email protected]>
The quilt patch titled
     Subject: mm: hugetlb: use error variable in alloc_hugetlb_folio
has been removed from the -mm tree.  Its filename was
     mm-hugetlb-use-error-variable-in-alloc_hugetlb_folio.patch

This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ackerley Tng <[email protected]>
Subject: mm: hugetlb: use error variable in alloc_hugetlb_folio
Date: Thu, 02 Jul 2026 09:21:48 -0700

Refactor alloc_hugetlb_folio to use a local variable for returning error
codes.  Instead of returning ERR_PTR(-ENOSPC) at the end of the error
path, assign -ENOSPC to a return variable at each failure point and return
that variable at the end.

This allows the cleanup goto targets to be used with other errors in a
later patch.

No functional change intended.

Link: https://lore.kernel.org/[email protected]
Signed-off-by: Ackerley Tng <[email protected]>
Cc: Alistair Popple <[email protected]>
Cc: Byungchul Park <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: "Edgecombe, Rick P" <[email protected]>
Cc: Frank van der Linden <[email protected]>
Cc: Gregory Price <[email protected]>
Cc: "Huang, Ying" <[email protected]>
Cc: James Houghton <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Jiaqi Yan <[email protected]>
Cc: Joshua Hahn <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: Michael Roth <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Pasha Tatashin <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Pratyush Yadav <[email protected]>
Cc: Qi Zheng <[email protected]>
Cc: Rakie Kim <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Sean Christopherson <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Shivank Garg <[email protected]>
Cc: Vishal Annapurve <[email protected]>
Cc: Yan Zhao <[email protected]>
Cc: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

 mm/hugetlb.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

--- a/mm/hugetlb.c~mm-hugetlb-use-error-variable-in-alloc_hugetlb_folio
+++ a/mm/hugetlb.c
@@ -2886,8 +2886,10 @@ struct folio *alloc_hugetlb_folio(struct
 	 */
 	if (map_chg) {
 		gbl_chg = hugepage_subpool_get_pages(spool, 1);
-		if (gbl_chg < 0)
+		if (gbl_chg < 0) {
+			ret = -ENOSPC;
 			goto out_end_reservation;
+		}
 	} else {
 		/*
 		 * If we have the vma reservation ready, no need for extra
@@ -2903,13 +2905,17 @@ struct folio *alloc_hugetlb_folio(struct
 	if (map_chg) {
 		ret = hugetlb_cgroup_charge_cgroup_rsvd(
 			idx, pages_per_huge_page(h), &h_cg_rsvd);
-		if (ret)
+		if (ret) {
+			ret = -ENOSPC;
 			goto out_subpool_put;
+		}
 	}
 
 	ret = hugetlb_cgroup_charge_cgroup(idx, pages_per_huge_page(h), &h_cg);
-	if (ret)
+	if (ret) {
+		ret = -ENOSPC;
 		goto out_uncharge_cgroup_reservation;
+	}
 
 	/* Takes reference on mpol. */
 	nid = huge_node(vma, addr, gfp, &mpol, &nodemask);
@@ -2940,6 +2946,7 @@ struct folio *alloc_hugetlb_folio(struct
 		folio = alloc_buddy_hugetlb_folio(h, gfp, &mpoli);
 		if (!folio) {
 			mpol_cond_put(mpol);
+			ret = -ENOSPC;
 			goto out_uncharge_cgroup;
 		}
 		spin_lock_irq(&hugetlb_lock);
@@ -3032,7 +3039,7 @@ out_subpool_put:
 out_end_reservation:
 	if (map_chg != MAP_CHG_ENFORCED)
 		vma_end_reservation(h, vma, addr);
-	return ERR_PTR(-ENOSPC);
+	return ERR_PTR(ret);
 }
 
 static __init void *alloc_bootmem(struct hstate *h, int nid, bool node_exact)
_

Patches currently in -mm which might be from [email protected] are