Re: [PATCH v3 4/4] mm/hugetlb: Convert use of struct page to folio in __unmap_hugepage_range()

Oscar Salvador
2025-04-30T08:09:29Z

On Mon, Apr 28, 2025 at 10:11:47AM -0700, nifan.cxl@gmail.com wrote:
> From: Fan Ni <fan.ni@samsung.com>
>
> In __unmap_hugepage_range(), the "page" pointer always points to the
> first page of a huge page, which guarantees there is a folio associating
> with it. Convert the "page" pointer to use folio.
>
> Signed-off-by: Fan Ni <fan.ni@samsung.com>
> ---
> mm/hugetlb.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 6696206d556e..293c2afa724b 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5815,12 +5815,12 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
> pte_t *ptep;
> pte_t pte;
> spinlock_t *ptl;
> - struct page *page;
> struct hstate *h = hstate_vma(vma);
> unsigned long sz = huge_page_size(h);
> bool adjust_reservation = false;
> unsigned long last_addr_mask;
> bool force_flush = false;
> + const bool folio_provided = !!folio;

This might be me just nitpicking but:

Why not rename folio to ref_folio o provided_folio and do

struct folio *folio = ref_folio;

I think it is more natural than the boolean.

Also you need to update the comment that references the 'reference page' and the one
David mentioned.

Anyway,

Reviewed-by: Oscar Salvador <osalvador@suse.de>

--
Oscar Salvador
SUSE Labs