Re: [PATCH v9 05/37] mm: hugetlb: remove dead alloc_hugetlb_folio stub
From: Dev Jain
Date: Mon Jun 01 2026 - 03:02:46 EST
On 29/05/26 8:52 pm, Michael S. Tsirkin wrote:
> Remove the !CONFIG_HUGETLB_PAGE stub for alloc_hugetlb_folio().
>
> The stub is dead code: all callers are in mm/hugetlb.c
> (CONFIG_HUGETLB_PAGE) or fs/hugetlbfs/inode.c (CONFIG_HUGETLBFS),
> and CONFIG_HUGETLB_PAGE is def_bool HUGETLBFS with nothing
> selecting it independently.
>
> The stub is also broken: it returns NULL, but all callers check
> IS_ERR(folio), so a NULL return would not be caught and would
> crash on the subsequent folio dereference.
>
> Remove it now since follow-up patches change the signature of
> alloc_hugetlb_folio and would otherwise need to update the
> broken stub too.
>
> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
> Reviewed-by: Gregory Price <gourry@xxxxxxxxxx>
> Assisted-by: Claude:claude-opus-4-6
> ---
Reviewed-by: Dev Jain <dev.jain@xxxxxxx>
> include/linux/hugetlb.h | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 93418625d3c5..f016bc2e8936 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -1129,13 +1129,6 @@ static inline void wait_for_freed_hugetlb_folios(void)
> {
> }
>
> -static inline struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
> - unsigned long addr,
> - bool cow_from_owner)
> -{
> - return NULL;
> -}
> -
> static inline struct folio *
> alloc_hugetlb_folio_reserve(struct hstate *h, int preferred_nid,
> nodemask_t *nmask, gfp_t gfp_mask)