Skip to contentSkip to conversation

mm-hugetlb-refactor-out-hugetlb_alloc_folio.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jul 31

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: hugetlb: refactor out hugetlb_alloc_folio()
has been removed from the -mm tree. Its filename was
mm-hugetlb-refactor-out-hugetlb_alloc_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: refactor out hugetlb_alloc_folio()
Date: Thu, 02 Jul 2026 09:21:50 -0700

Refactor out hugetlb_alloc_folio() from alloc_hugetlb_folio(), which handles allocation of a folio and memory and HugeTLB charging to cgroups.

This refactoring decouples the HugeTLB page allocation from VMAs, specifically:

1. Reservations (as in resv_map) are stored in the vma
2. mpol is stored at vma->vm_policy
3. A vma must be used for allocation even if the pages are not meant to be used by host process.

Without this coupling, VMAs are no longer a requirement for allocation. This opens up the allocation routine for usage without VMAs, which will allow guest_memfd to use HugeTLB as a more generic allocator of huge pages, since guest_memfd memory may not have any associated VMAs by design. In addition, direct allocations from HugeTLB could possibly be refactored to avoid the use of a pseudo-VMA.

Also, this decouples HugeTLB page allocation from HugeTLBfs, where the subpool is stored at the fs mount. This is also a requirement for guest_memfd, where the plan is to have a subpool created per-fd and stored on the inode.

Provide and use alloc_flags to allow more allocation knobs in future without expanding the number of parameters in hugetlb_alloc_folio().

No functional change intended.

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 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]>
Cc Qi Zheng <[email protected]>

---

 include/linux/hugetlb.h |   18 +++
 mm/hugetlb.c            |  206 ++++++++++++++++++++------------------
 2 files changed, 131 insertions(+), 93 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-hugetlb-refactor-out-hugetlb_alloc_folio +18 -0
@@ -2,6 +2,7 @@
 #ifndef _LINUX_HUGETLB_H
 #define _LINUX_HUGETLB_H
 
+#include <linux/mempolicy.h>
 #include <linux/mm.h>
 #include <linux/mm_types.h>
 #include <linux/mmdebug.h>
@@ -682,6 +683,23 @@ struct hstate {
 int isolate_or_dissolve_huge_folio(struct folio *folio, struct list_head *list);
 int replace_free_hugepage_folios(unsigned long start_pfn, unsigned long end_pfn);
 void wait_for_freed_hugetlb_folios(void);
+
+struct mempolicy_interpreted {
+	int nid;
+	nodemask_t *nodemask;
+	enum mempolicy_mode mode;
+};
+
+enum hugetlb_alloc_flag {
+	HUGETLB_ALLOC_CHARGE_CGROUP_RSVD_BIT = 0,
+	HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS_BIT,
+};
+
+#define HUGETLB_ALLOC_CHARG_CGROUP_RSVD BIT(HUGETLB_ALLOC_CHARGE_CGROUP_RSVD_BIT)
+#define HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS BIT(HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS_BIT)
+
+struct folio *hugetlb_alloc_folio(struct hstate *h,
+		struct mempolicy_interpreted *mpoli, u8 alloc_flags);
 struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
 				unsigned long addr, bool cow_from_owner);
 struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int preferred_nid,
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-refactor-out-hugetlb_alloc_folio +113 -93

258 lines not on this page · raw message

_

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