Re: [PATCH v4 5/6] mm: convert copy_user_huge_page() to copy_user_folio()

Matthew Wilcox
2023-03-30T18:16:05Z

On Thu, Mar 30, 2023 at 09:40:44PM +0800, Peng Zhang wrote:
> +void copy_user_folio(struct folio *dst, struct folio *src,
> + unsigned long addr_hint,
> + struct vm_area_struct *vma,
> + unsigned int pages_per_huge_page);

Do we really want to pass in pages_per_huge_page here? We can get
that from folio_nr_pages(dst).

> +++ b/mm/hugetlb.c
> @@ -5097,8 +5097,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
> ret = PTR_ERR(new_folio);
> break;
> }
> - copy_user_huge_page(&new_folio->page, ptepage, addr, dst_vma,
> - npages);
> + copy_user_folio(new_folio, page_folio(ptepage), addr, dst_vma,
> + npages);
> put_page(ptepage);

This function should be converted to s/ptepage/pte_folio/, but that's
not for this patch series.

> - copy_user_huge_page(&new_folio->page, old_page, address, vma,
> - pages_per_huge_page(h));
> + copy_user_folio(new_folio, page_folio(old_page), address, vma,
> + pages_per_huge_page(h));

Likewise for s/old_page/old_folio/