Re: [PATCH v4 1/6] userfaultfd: convert mfill_atomic_pte_copy() to use a folio

From: zhangpeng (AS)
Date: Fri Mar 31 2023 - 05:39:06 EST


On 2023/3/31 2:02, Matthew Wilcox wrote:

On Thu, Mar 30, 2023 at 10:02:52AM -0700, Sidhartha Kumar wrote:
On 3/30/23 6:40 AM, Peng Zhang wrote:
From: ZhangPeng <zhangpeng362@xxxxxxxxxx>

Call vma_alloc_folio() directly instead of alloc_page_vma(). Add an
assertion that this is a single-page folio and removes several calls to
compound_head().
There's no added assertion in this patch any more, so I'd drop that
part of the description.

Thanks. I'll update this description.

if (!*pagep) {
ret = -ENOMEM;
- page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, dst_vma, dst_addr);
- if (!page)
+ folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, dst_vma, dst_addr, false);
+ if (!folio)
goto out;
- page_kaddr = kmap_local_page(page);
+ page_kaddr = kmap_local_folio(folio, 0);
Should this variable name be kept as page_kaddr or should it be changed to
something like folio_kaddr? kmap_local_folio() returns page_address(), so
maybe page_kaddr is better.
I'd just call it 'kaddr'. Or 'addr'.

Agreed. I'll change page_kaddr to kaddr.

Thanks for your review.

Best Regards,
Peng