Re: [PATCH v2 1/6] mm: hugetlb: Consolidate interpretation of gbl_chg within alloc_hugetlb_folio()

From: Oscar Salvador

Date: Tue May 12 2026 - 05:23:21 EST


On Wed, May 06, 2026 at 08:54:37AM -0700, Ackerley Tng via B4 Relay wrote:
> From: Ackerley Tng <ackerleytng@xxxxxxxxxx>
>
> The dequeue_hugetlb_folio_vma() function currently handles the gbl_chg
> parameter to determine if a folio can be dequeued based on global page
> availability. This leaks reservation-specific logic into the dequeueing
> path.
>
> Relocate this logic to alloc_hugetlb_folio() so that
> dequeue_hugetlb_folio_vma() focuses solely on selecting and dequeuing a
> folio. In alloc_hugetlb_folio(), only attempt to dequeue a folio if a
> reservation exists (gbl_chg == 0) or if there are available huge pages in
> the global pool.
>
> No functional change intended.
>
> Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Reviewed-by: James Houghton <jthoughton@xxxxxxxxxx>

Acked-by: Oscar Salvador <osalvador@xxxxxxx>

I am ok with this but:

> ---
> mm/hugetlb.c | 24 +++++++++---------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index f24bf49be047e..8be246b4e6134 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
...
> @@ -2939,12 +2929,16 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
> goto out_uncharge_cgroup_reservation;
>
> spin_lock_irq(&hugetlb_lock);
> +
> /*
> - * glb_chg is passed to indicate whether or not a page must be taken
> - * from the global free pool (global change). gbl_chg == 0 indicates
> - * a reservation exists for the allocation.
> + * gbl_chg == 0 indicates a reservation exists for the allocation - so
> + * try dequeuing a page. If there are available_huge_pages(), try using
> + * them!

This comment is a bit obfuscated.

I miss "in case there is no reservation, check whether we have available
pages in the pool to satisfy the request"

or something like that.



--
Oscar Salvador
SUSE Labs