Re: [PATCH v2 2/6] mm: hugetlb: Move mpol interpretation out of alloc_buddy_hugetlb_folio_with_mpol()

From: Oscar Salvador

Date: Tue May 12 2026 - 08:56:29 EST


On Wed, May 06, 2026 at 08:54:38AM -0700, Ackerley Tng via B4 Relay wrote:
> From: Ackerley Tng <ackerleytng@xxxxxxxxxx>
>
> Move memory policy interpretation out of
> alloc_buddy_hugetlb_folio_with_mpol() and into alloc_hugetlb_folio() to
> separate reading and interpretation of memory policy from actual
> allocation.
>
> This will later allow memory policy to be interpreted outside of the
> process of allocating a hugetlb folio entirely. This opens doors for other
> callers of the HugeTLB folio allocation function, such as guest_memfd,
> where memory may not always be mapped and hence may not have an associated
> vma.
>
> No functional change intended.
>
> Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Reviewed-by: James Houghton <jthoughton@xxxxxxxxxx>

Acked-by: Oscar Salvador <osalvador@xxxxxxx>

> ---
> mm/hugetlb.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 8be246b4e6134..ea3bc405b3162 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -2160,15 +2160,11 @@ static struct folio *alloc_migrate_hugetlb_folio(struct hstate *h, gfp_t gfp_mas
> */
> static
> struct folio *alloc_buddy_hugetlb_folio_with_mpol(struct hstate *h,
> - struct vm_area_struct *vma, unsigned long addr)
> + struct mempolicy *mpol, int nid, nodemask_t *nodemask)
> {
> struct folio *folio = NULL;
> - struct mempolicy *mpol;
> gfp_t gfp_mask = htlb_alloc_mask(h);

You already get gfp_mask back in alloc_hugetlb_folio(), so maybe just
pass it here, so it is clearer to the reader that these are no different
masks.



--
Oscar Salvador
SUSE Labs